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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
How about something like this, (your value in A7);

Code:
=IF(A7>24,TEXT(A7,"dd/mm/yy"),A7)
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
#,##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
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,777
Members
448,991
Latest member
Hanakoro

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