Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Fixing the date format in a macro or VBA | Excel Worksheet Functions | |||
Message box date format macro help | Excel Worksheet Functions | |||
Message box date format macro help | Excel Worksheet Functions | |||
date format problem using Macro | Excel Discussion (Misc queries) | |||
date format changes when I save to CSV via a macro | Excel Discussion (Misc queries) |