![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Jan 2003
Posts: 611
|
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 |
|
|
|
|
|
#2 |
|
Join Date: Apr 2002
Posts: 2,314
|
How about something like this, (your value in A7);
Code:
=IF(A7>24,TEXT(A7,"dd/mm/yy"),A7) |
|
|
|
|
|
#3 |
|
Join Date: Jan 2003
Posts: 611
|
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 |
|
|
|
|
|
#4 |
|
Join Date: Apr 2002
Posts: 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 |
|
|
|
|
|
#5 |
|
Join Date: Jan 2003
Posts: 611
|
#,##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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|