• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

macro by click activecell.value to range cell

koi

Member
hi All,


i got this macro from chandoo posting about how to click on cell then will trigger pivot table to filter.


question is.. can i make the activecell to range example b5:b10? so when i click another cell it wont trigger the macro.


nowdays i have to protect sheets and allow only range b5:b10 so it wont show error macro message :)


thanks


=========================================================================

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Range("C1").Value = ActiveCell.Value

[Name Range] = [Name Range]

End Sub
 
Sure thing. This should help you out.

[pre]
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myRange As Range
'What range of cells shall act as our trigger?
Set myRange = Range("B5:B10")

'Check to see if we clicked on a cell of interest
If Intersect(myRange, Target) Is Nothing Then Exit Sub

Range("C1").Value = ActiveCell.Value
[Name Range] = [Name Range]
End Sub
[/pre]
 
Back
Top