How to specify which cells/columns macro applies to?

G

Guest

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
 
O

Otto Moehrbach

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
 

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