How to restrict macro execution to a column subset?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have recorded a macro which does several find & replace text function. I
would like it to perform these function only on a specific column; not the
entire spreadsheet. What is the macro syntax for doing this?
 
This is just an example of what I have, when I right click on the mouse
a userform shows, this only works in column A


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If Union(Range("$A:$A"), Target).Address = Range("$A:$A").Address Then
userform1.Show
Cancel = True
End If
End Sub
 
If Union(Range("$A:$A"), Target).Address =
Range("$A:$A").Address Then

That's rather cumbersome code. Why not just

If Target.Column = 1 Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
THAT'S GREAT,
1 meaning column A of course
and then an End If
How come I ended up with the other code, I don't know!!
Dave
 
Back
Top