Setting target address

Dryver14

Well-known Member
Joined
Mar 22, 2010
Messages
2,396
in a response to an earlier question the answer was to say that the if target address was <> $E$5 then........

can you not say target address =

Not trying to be funny, this address issue is somehow eluding me.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
You could say
Code:
if target.address <> "$E$5" then
    Range("YourNewCell").Value = Target.value
    Target.clearcontents
end if
 
Upvote 0
so when you initially start a worksheet change event

lets say i want it only to act on

well if you could, could I have 2 examples.

A5

and

A:A

I would appreciate it very much.

Thanks in advance
 
Upvote 0
Code:
if target.address <> "$E$5" then
    Range("A5").Value = Target.value
    Target.clearcontents
end if

Code:
if target.address <> "$E$5" then
    Range("A:A").Value = Target.value
    Target.clearcontents
end if

Or do you mean you only want it invoked when an entry is made in A?
 
Upvote 0
yes blade I'm sorry for confusing you, $E$5 was in someone elses question which provoked mine.

I just want to know how to initially set a target address to anything and would appreciate an example of a singe cell and a range please.
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'If Target.Address <> "$A$2" Then 'Use this to monitor a cell
If Target.Column = 1 Then 'Use this to monitor a column
    Range("B1").Value = Target.Value 'This is the cell that will be updated instead (but really it just copies)
    Target.ClearContents 'Clear the entry from the original target
End If
Application.EnableEvents = True
End Sub

Uncomment whichever one you need, the first one monitors a cell, the second a column (Column 1 being Column A)

Edit: Updated to stop infinate loop
 
Upvote 0
Thanks Blade I really appreciate it.

My understanding is this.

The target is not something I set it is whatever is keyed on the sheet by the operator and it is up to me to direct their input to the response I would like but i can say if it is not something (cell or range) then do nothiing.
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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