Conditional Formatting either Date or Number

ken2step

Well-known Member
Joined
Jan 9, 2003
Messages
642
I been racking my brain to figure out a way to do this. What I have is a equipment list that has either Due Hours or Due Dates. I would like to have the format for the cell entry to be tied to an adjacent cell say, that would have either Number or Date in it to tell the entry cell which custom format to apply to the entered data. Does anyone have any ideas for me. I have tried Conditional Formatting but it is only for Font Style.
Thanks,
Ken
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

jimboy

Well-known Member
Joined
Apr 11, 2002
Messages
2,314
How about something like this, (your value in A7);

Code:
=IF(A7>24,TEXT(A7,"dd/mm/yy"),A7)
 

ken2step

Well-known Member
Joined
Jan 9, 2003
Messages
642
That was a good idea, but I guess I was not clear. The hours I am talking about are reading from Hour Meters. So they can be anything from 0 to 15,000 if you get my drift here. So your idea was good, but I am wanting to change the format of the cell the data is entered into according to the data entered, like Conditional Formatting, but either a Date format or a Number format. Once you enter a Date into a cell the format will remain a Date format unless you manually change it. I hope this is more clear as to what my problem is.
Ken
 

jimboy

Well-known Member
Joined
Apr 11, 2002
Messages
2,314
If you right mouse over the sheet name and select view code, then paste this in, it will format the changed cell to dd/mm/yy if it's a date (will run on column 4 only, change to your column)

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub

'will only run on column 4 i.e. D
If Target.Column <> 4 Then Exit Sub

If isdate(Target) = True Then Target.NumberFormat = "dd/mm/yyyy"
End Sub

What is your other format?
 

ken2step

Well-known Member
Joined
Jan 9, 2003
Messages
642
#,##0

Thanks alot!! I don't know VBA, but have experimented and played with it. I guess I need to learn it soon. I figured this would be the solution, but was hoping it was not. he he.....I appreciate your response and look forward to the updated version with this format included. I will try and learn from your post.
Thanks again!
Ken
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,185
Messages
5,857,833
Members
431,900
Latest member
Paradime0346

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
Top