If cell has a value do nothing

Mikeymike_W

Board Regular
Joined
Feb 25, 2016
Messages
171
Hi all,

I have the following bit of code that supplies a time stamp in column Z when the cell in column G is populated:

If Target.Column = 7 Then
Application.EnableEvents = False
Cells(Target.Row, 26).Value = Date + Time
Application.EnableEvents = True
End If

I wanted to bypass this code if there is already a value in column Z so if the user alters the value in column G then a new date is not entered in column Z and it stays the same.

Thanks in advance,

Mike
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Change:

Code:
[COLOR=#333333]If Target.Column = 7 Then[/COLOR]


to

Code:
[COLOR=#333333]If Target.Column = 7 and Cells(Target.Row, 26) = "" Then[/COLOR]
 
Upvote 0
maybe:

If Target.Column = 7 Then
If isempty(cells(target.row,"Z")) then
Application.EnableEvents = False
Cells(Target.Row, 26).Value = Date + Time
Application.EnableEvents = True
End If
end if
 
Upvote 0
Hi Guys,

thanks very much for your help.

I tried both methods and they both work well.

Personally I prefer Erics method as it seems tidier.

Many thanks again,

Mike
 
Upvote 0

Forum statistics

Threads
1,215,180
Messages
6,123,502
Members
449,100
Latest member
sktz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top