Hi I need help running his if not found, If What:= is not found then do nothing. Right now lets say I run both if what I said is not found it breaks (debugs).
I would like for it not to break if its not found.
Do I need something like this On Error GoTo Done: ? Somewhere not sure. Any help thanks
I would like for it not to break if its not found.
Do I need something like this On Error GoTo Done: ? Somewhere not sure. Any help thanks
Code:
Sub MoveRangeIfNotBlank250()
'Move value to other cell if next cell is empty'
Dim Scol As Long
Dim Dcol As Long
Dim Rng As Range
Dim Ofst As Long
Scol = Rows(1).Find(What:="SALARY AMOUNT", After:=Range("A1"), _
lookat:=xlWhole, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column
Dcol = Rows(1).Find(What:="HOURLY AMOUNT", After:=Range("A1"), _
lookat:=xlWhole, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column
Ofst = Scol - Dcol
For Each Rng In Range(Cells(2, Dcol), Cells(Rows.count, Dcol).End(xlUp))
If Len(Rng.value) = 0 And Len(Rng.Offset(, Ofst).value) <> 0 Then
Rng.value = Rng.Offset(, Ofst).value
Rng.Offset(, Ofst).Clear
End If
Next Rng
End Sub
Code:
Sub MoveRangeIfNotBlank251()
'Move value to other cell if next cell is empty'
Dim Scol As Long
Dim Dcol As Long
Dim Rng As Range
Dim Ofst As Long
Scol = Rows(1).Find(What:="HOURLY DAYS", After:=Range("A1"), _
lookat:=xlWhole, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column
Dcol = Rows(1).Find(What:="HOURLY HOURS", After:=Range("A1"), _
lookat:=xlWhole, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column
Ofst = Scol - Dcol
For Each Rng In Range(Cells(2, Dcol), Cells(Rows.count, Dcol).End(xlUp))
If Len(Rng.value) = 0 And Len(Rng.Offset(, Ofst).value) <> 0 Then
Rng.value = Rng.Offset(, Ofst).value
Rng.Offset(, Ofst).Clear
End If
Next Rng
End Sub
Last edited: