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

LloydFinancials

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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,247
Office Version
  1. 365
Platform
  1. Windows
In future when posting code please use code tags. How to Post Your VBA Code

Is the sheet protected?
Do you have any merged cells?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
38,110
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,403
Messages
5,769,872
Members
425,576
Latest member
niall54321

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