Worksheet.Selection.Change not working for select statement but works for columns 1 and 2

LloydFinancials

Well-known Member
Joined
Apr 24, 2015
Messages
546
Getting Runtime Error '1004': Select method of range class failed on the line Cells(r3.Row, r2.Column).Select. If I print Cells(r3.Row, R2.Column).address I get the address, but it won't go to the cell.

Please advise, Thanks, Luke

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 1 Then
If Selection.Cells.Count = 1 Then
If Len(Target.Value) > 0 Then
Dim r1 As Range
Dim r2 As Range
Dim r3 As Range
Dim fs1 As String
Dim fs2 As String
Dim fs3 As String
fs1 = Target.Value
fs2 = Cells(3, Target.Column).Value
Sheets("Monthly Actuals - Research").Select
With Sheets("Monthly Actuals - Research").Columns(1)
Set r1 = .Find(What:=fs1, _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
End If
End If
Sheets("Monthly Actuals - Research").Cells(r1.Row, 1).Select
End If

If Target.Column = 2 Then
If Selection.Cells.Count = 1 Then
If Len(Target.Value) > 0 Then
fs1 = Target.Value
Sheets("Monthly Actuals - Research").Select
With Sheets("Monthly Actuals - Research").Columns(2)
Set r1 = .Find(What:=fs1, _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
End If
End If
Sheets("Monthly Actuals - Research").Cells(r1.Row, 2).Select
End If

Select Case Target.Column
Case 45, 46, 47, 48, 49, 50
fs2 = Cells(3, Target.Column).Value
fs3 = Cells(Target.Row, 1).Value
With Sheets("Monthly Actuals - Research").Rows(4)
Set r2 = .Find(What:=fs2, _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
With Sheets("Monthly Actuals - Research").Columns(1)
Set r3 = .Find(What:=fs3, _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
End Select
Sheets("Monthly Actuals - Research").Select
Cells(r3.Row, r2.Column).Select
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I guess the code is not in the "Monthly Actuals - Research" sheet? You probably need:

Code:
With Sheets("Monthly Actuals - Research")
   .Select
   .Cells(r3.Row, r2.Column).Select
End With
 
Upvote 0

Forum statistics

Threads
1,222,313
Messages
6,165,291
Members
451,950
Latest member
WH2000

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