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

LloydFinancials

Well-known Member
Joined
Apr 24, 2015
Messages
539
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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
40,118
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
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,186,363
Messages
5,957,425
Members
438,305
Latest member
farmerje

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
Top