I am using this code to select an range by reference for copy and paste. It shows error in the Consultant3.Select
line.
I am unable to fix this code.
Sub SelectMyRange()
Dim Consultant1 As Integer, Consultant2 As Integer
Dim Consultant3 As Range
Dim rngFind As Range
Set rngFind = Columns("A:A").Find(What:="OBJ NO.", After:=Range("A1"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not rngFind Is Nothing Then
Consultant1 = rngFind.Row + 2
End If
Set rngFind = Columns("A:A").Find(What:="OBJ END", After:=Range("A1"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not rngFind Is Nothing Then
Consultant2 = rngFind.Row - 1
End If
If Consultant1 > 0 And Consultant2 > 0 Then
Set Consultant3 = Range(Cells(Consultant1, 1), Cells(Consultant2, 1))
End If
Consultant3.Select
Selection.Copy
End Sub