NorthbyNorthwest
Board Regular
- Joined
- Oct 27, 2013
- Messages
- 178
- Office Version
- 365
Hi, everyone. Could someone please tell me why I get an "object variable or with block variable not set" error when I run this code? Note: I do not get an error on first run of line. But I do get it on second run (line in green text). What do I have wrong?
VBA Code:
Sub ShuffleBoard()
Dim ws As Worksheet
Dim RowNum As Long
Dim ReturnRowNum As Long
Dim SearchRange As Range
Dim rng As Range
Dim rng1 As Range
Dim FindRow As Range
Call ShowCalculator
Worksheets("Assignments").Activate
Set ws = Worksheets("Assignments")
Set SearchRange = ws.Range("AP6:AP52")
Set FindRow = SearchRange.Find("Auditor", LookIn:=xlValues, LookAt:=xlWhole)
If Not FindRow Is Nothing Then ReturnRowNum = FindRow.Row
RowNum = FindRow.Row
Set rng = ws.Range("AP6")
rng.Cut
ws.Range(Cells(RowNum, 42), Cells(RowNum, 42)).Insert Shift:=xlDown
Set SearchRange = ws.Range("M8:V39")
Set FindRow = SearchRange.Find("Auditor", LookIn:=xlValues, LookAt:=xlWhole)
If Not FindRow Is Nothing Then ReturnRowNum = FindRow.Row
[COLOR=rgb(65, 168, 95)] RowNum = FindRow.Row[/COLOR]
Set rng1 = ws.Range("M8")
rng1.Cut
ws.Range(Cells(RowNum, 13), Cells(RowNum, 13)).Insert Shift:=xlDown
Range("AN1").Select
End Sub