FOR MIKE H.

D

doss04

I apologize for contacting you this way. But once i replied that my last post
was answered i didn't think you would check it again. You helped me with the
clicking a cell and having the time appear. Well i have another question
regarding that. The formula you gave works great by the way. Now I'm trying
to do individual cells. I've tried working around it myself, but all i get is
either the entire column or row gets formatted. Not the cells i'm trying.
Could you help again? Thanks
 
S

Sean Timmons

Here's the previous post....
Answer from Mike H on top, initial post on bottom, but I believe it only
needs a simple addition, see below.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 5 AND Target.Row = 4 Then
If IsEmpty(Target) Then Target.Value = Time
End If
End Sub

Assuming you want to click in cell E4

________________________________________
Hi,

It colud be done like this. Right click your sheet tab, view code and paste
this in on the right. Change the 5 (Column E) to the appropriate column. It
can be written so that this only happens in certain cells and if you need
more help post back.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 5 Then
If IsEmpty(Target) Then Target.Value = Time
End If
End Sub

Mike
 
D

doss04

That worked, i just cant get it to work on other cells. How do i do multiple
cells through out the worksheet?
 
S

Sean Timmons

This will depend on where your other cells are. If all in the same row, use:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Select Case Target.Column
Case 5, 6, 8
If Target.Row = 4 Then
If IsEmpty(Target) Then Target.Value = Time
End If
End Select
End Sub

Which will enter the time if you are in cells E4, F4 OR H4.

If in the same column, reverse where I have Column and Row in the above.

If in a mixture of both, use multiple Case statements..

Case 4
If x Then Y
Case 8
If a Then B
etc.
End Select
 
B

Bob Phillips

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "E4,F5,G6,H1"

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

If IsEmpty(Target) Then Target.Value = Time
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top