Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:48:26+00:00 2026-05-31T12:48:26+00:00

I have a several columns in my excel worksheets which are all named as

  • 0

I have a several columns in my excel worksheets which are all named as “Date”. I want to write a code which will find all date columns in all worksheets and format the values in that column as “dd/mm/yyyy;@” .

In the code below I tried writing Columns(“Date”).Select instead of Columns(“E:E”).Select but this is not working. Can anyone suggest me how to fix this?

Thanks for your time and suggestions.

Sub dateformat()      
Dim ws As Worksheet     
For Each ws In Worksheets         
Columns("E:E").Select         
Selection.NumberFormat = "dd/mm/yyyy;@"             
Next ws  
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:48:28+00:00Added an answer on May 31, 2026 at 12:48 pm

    Nupur, Is this what you are trying?

    Option Explicit
    
    Sub Sample()
        Dim aCell As Range, bCell As Range
        Dim ws As Worksheet
        Dim ExitLoop As Boolean
    
        For Each ws In ThisWorkbook.Sheets
    
            Set aCell = ws.Rows(1).Find(what:="Date", LookIn:=xlValues, _
            lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
    
            ExitLoop = False
    
            If Not aCell Is Nothing Then
                Set bCell = aCell
    
                ws.Columns(aCell.Column).NumberFormat = "dd/mm/yyyy;@"
                Do While ExitLoop = False
                    Set aCell = ws.Rows(1).FindNext(After:=aCell)
    
                    If Not aCell Is Nothing Then
                        If aCell.Address = bCell.Address Then Exit Do
                        ws.Columns(aCell.Column).NumberFormat = "dd/mm/yyyy;@"
                    Else
                        ExitLoop = True
                    End If
                Loop
            End If
        Next
    End Sub
    

    FOLLOWUP

    The reason you are getting those errors is because your column is formatted as text. Try this. This works 🙂

    Option Explicit
    
    Sub Sample()
        Dim aCell As Range, bCell As Range
        Dim ws As Worksheet
        Dim lastRow As Long, i As Long
        Dim ExitLoop As Boolean
    
        For Each ws In ThisWorkbook.Sheets
            Set aCell = ws.Rows(1).Find(what:="Date", LookIn:=xlValues, _
            lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
    
            ExitLoop = False
    
            If Not aCell Is Nothing Then
                Set bCell = aCell
    
                ws.Columns(aCell.Column).NumberFormat = "dd/mm/yyyy;@"
    
                lastRow = ws.Range(Split(ws.Cells(, aCell.Column).Address, "$")(1) & _
                ws.Rows.Count).End(xlUp).Row
    
                For i = 2 To lastRow
                    With ws.Range(Split(ws.Cells(, aCell.Column).Address, "$")(1) & i)
                        .FormulaR1C1 = .Value
                    End With
                Next i
    
                ws.Columns(aCell.Column).AutoFit
    
                Do While ExitLoop = False
                    Set aCell = ws.Rows(1).FindNext(After:=aCell)
    
                    If Not aCell Is Nothing Then
                        If aCell.Address = bCell.Address Then Exit Do
    
                        ws.Columns(aCell.Column).NumberFormat = "dd/mm/yyyy;@"
    
                        lastRow = ws.Range(Split(ws.Cells(, aCell.Column).Address, "$")(1) & _
                        ws.Rows.Count).End(xlUp).Row
    
                        For i = 2 To lastRow
                            ws.Range(Split(ws.Cells(, aCell.Column).Address, "$")(1) & i).FormulaR1C1 = _
                            ws.Range(Split(ws.Cells(, aCell.Column).Address, "$")(1) & i).Value
                        Next i
                    Else
                        ExitLoop = True
                    End If
                Loop
            End If
        Next
    End Sub
    

    HTH

    Sid

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several columns that I'd like to search against. My code might not
I have several TextField columns on my UserProfile object which contain JSON objects. I've
I have several files and I only want to take specific columns from it.
I have a file from which I've output several columns of information, 4 to
I have a table called scheduler_sched which has several columns, including a column called
I have an Ext.grid.EditorGridPanel in which I defined several columns. Per each of the
Excel 2007: I have an app which outputs several rows, with pipe delimiters, into
This is on SQL Server 2008. I have several columns I want to convert
I have several columns and making pivot. I want to have multiple non-pivot columns
I'm restructuring my MySQL database, which has several columns in Unix format. Because I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.