Displaying cell contents based on input?
Hi Fleone,
Here is some event code that works for A1:A100
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:A100")) Is Nothing Then
With Target
Select Case .Value
Case 9 / 24: .NumberFormat = "@"
.Value = "9 - 6"
Case 10 / 24: .NumberFormat = "@"
.Value = "10 - 7"
Case 12 / 24: .NumberFormat = "@"
.Value = "12 - 9"
Case Else: .Value = "Invalid input"
.NumberFormat = "hh:mm"
End Select
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Fleone" wrote in message
...
I posted this question a few weeks back and wasn't able to come up with a
viable solution, so I post it again in hopes that some fresh eyes might
come
across it.
What I would like to do is have a cell display differently than the data
input.
Specifically I am working on a schedule. There are three shifts, one 9 am
to
6 pm, one 10 am to 7 pm and one 12 pm to 9 pm.
Here is what I would like to do:
If I enter 09:00 in a particular cell, I would like the cell itself to
display 9 - 6, the same thing would apply for the other shifts, 10:00
entered
would display 10 - 7, and 12:00 entered would display 12 - 9.
I am looking for this type of solution because I will be having several
other worksheets refering to a "master" schedule worksheet.
Anyway, I have never written a visual basic script of my own, through the
kindness and expertise of others here, I have been able to take some and
modify them to my needs, but have to admit to being relatively LOST when
confronted with the task of starting from scratch.
If anyone can point me in the proper direction, or give me some ideas on
where to start, I would greatly appreciate it.
Thanks.
|