View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default How to specify which cells/columns macro applies to?

Say that you want the date and time to be placed in Column D if an entry is
made in Column C:
If Target.Column=3 Then Target.Offset(,1).Value = Now
HTH Otto

"Workaholic" wrote in message
...
I found the macro I need to automatically display the current date and time
when an entry is made in the row. The problem is I only want it to look
at
the adjacent column. I don't want it to start at column A and I don't
want
it to look at the entire rows entries. How to I specify which
column/cells
the macro is applied to and how do I make it look at only the next columns
entries? There are other columns/data in my worksheet I do not want
effected. Here's the macro I'm using. Please help and/or tell me where I
can get this info. Thanks in advance. Macro I'm using is below.

Private Sub Worksheet_Change(ByVal Target As Range)
If target.row = 1 then exit sub 'don't touch if 1st row
If target.column = 1 then exit sub 'don't touch with macro if target is
column A
If IsEmpty(target) then exit sub 'allow deletion of cell content in
entire row
If Not IsEmpty(Cells(Target.Row, 1)) Then Exit Sub 'ignore if already
has
a value
Cells(Target.Row, 1) = Now '--Column should be preformatted
End Sub