Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
sw sw is offline
external usenet poster
 
Posts: 4
Default Macro to format date

I am looking for some code that will look through my
spreadsheet, find all columns headers called "Date" (which
will always be in row 1) and on finding a date column
format all cells in that column to the date format
dd/mm/yy.

Can anyone help with this.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to format date

Try this one.

Sub Macro1()
Dim X As Long
For X = 1 To 256
If Cells(1, X) = "Date" Then
Columns(X).NumberFormat = "dd/mm/yy"
End If
Next X
End Sub

Ecco


-----Original Message-----
I am looking for some code that will look through my
spreadsheet, find all columns headers called "Date"

(which
will always be in row 1) and on finding a date column
format all cells in that column to the date format
dd/mm/yy.

Can anyone help with this.

Thanks
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
sw sw is offline
external usenet poster
 
Posts: 4
Default Macro to format date

I entered this code as it is stated below and ran the
macro but nothing happened! Any idea why

-----Original Message-----
Try this one.

Sub Macro1()
Dim X As Long
For X = 1 To 256
If Cells(1, X) = "Date" Then
Columns(X).NumberFormat = "dd/mm/yy"
End If
Next X
End Sub

Ecco


-----Original Message-----
I am looking for some code that will look through my
spreadsheet, find all columns headers called "Date"

(which
will always be in row 1) and on finding a date column
format all cells in that column to the date format
dd/mm/yy.

Can anyone help with this.

Thanks
.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to format date

Check if title Date is really written like Data (not like
date or DATE). You could change the IF-statement like this:

If Lcase(Cells(1,X))="date" Then

That´s the only idea I come up with. Hope it works.

Ecco

-----Original Message-----
I entered this code as it is stated below and ran the
macro but nothing happened! Any idea why

-----Original Message-----
Try this one.

Sub Macro1()
Dim X As Long
For X = 1 To 256
If Cells(1, X) = "Date" Then
Columns(X).NumberFormat = "dd/mm/yy"
End If
Next X
End Sub

Ecco


-----Original Message-----
I am looking for some code that will look through my
spreadsheet, find all columns headers called "Date"

(which
will always be in row 1) and on finding a date column
format all cells in that column to the date format
dd/mm/yy.

Can anyone help with this.

Thanks
.

.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to format date


Sub Macro1()
Dim X As Long
For X = 1 To 256
If Instr(1,Cells(1, X).Value,"date",vbTextCompare) Then
Columns(X).NumberFormat = "dd/mm/yy"
End If
Next X
End Sub

--
Regards,
Tom Ogilvy

"sw" wrote in message
...
I entered this code as it is stated below and ran the
macro but nothing happened! Any idea why

-----Original Message-----
Try this one.

Sub Macro1()
Dim X As Long
For X = 1 To 256
If Cells(1, X) = "Date" Then
Columns(X).NumberFormat = "dd/mm/yy"
End If
Next X
End Sub

Ecco


-----Original Message-----
I am looking for some code that will look through my
spreadsheet, find all columns headers called "Date"

(which
will always be in row 1) and on finding a date column
format all cells in that column to the date format
dd/mm/yy.

Can anyone help with this.

Thanks
.

.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fixing the date format in a macro or VBA Geoff B Excel Worksheet Functions 1 September 7th 09 11:00 AM
Message box date format macro help Aaron Excel Worksheet Functions 2 June 16th 09 08:16 AM
Message box date format macro help Aaron Excel Worksheet Functions 2 June 16th 09 07:17 AM
date format problem using Macro mohavv Excel Discussion (Misc queries) 1 October 15th 08 01:09 AM
date format changes when I save to CSV via a macro John Taylor Excel Discussion (Misc queries) 4 May 16th 07 01:44 PM


All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"