Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How to specify which cells/columns macro applies to?

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

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


All times are GMT +1. The time now is 02:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"