Number Format by searching word for a Row

Shreesurya

Board Regular
Joined
Jul 7, 2014
Messages
50
Hi,

Can you please help me to write a macro that search first Row and if its finds the word "Date" then the whole column should select and change the Number formatting to Date, and if it finds the word "Time" it should change the formatting for the whole column to Time.

Below is the format of Table where it should change the formatting of Date, Start Time and End Time.
DateOrderNumberStart TimeStatusEnd Time
41841******0.994444444WIP
41842*****0.994444444Completed0.9955555
41843*****0.994444444Completed0.9955555
41845*****0.994444444Completed0.9955555

<tbody>
</tbody>

Thanks in Advance for your Code :)

Surya Prakash...
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Sub Converter()
For i = 1 To Range("XFD1").End(xlToLeft).Column
Select Case True
Case InStr(Cells(1, i), "Date") > 0
Columns(i).NumberFormat = "m/d/yy"
Case InStr(Cells(1, i), "Time") > 0
Columns(i).NumberFormat = "h:mm:ss AM/PM"
End Select
Next
End Sub
 
Upvote 0
Thank you so much for your Code, it works perfect !

Just one issue, if Cell is updated in lower case (time instead of Time) then the Number format is not changing,

Could you please help me to modify this Code ?
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,732
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top