![]() |
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 |
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 |
All times are GMT +1. The time now is 08:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com