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
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