abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,429
- Office Version
- 2019
- 2010
- Platform
- Windows
hello
this code works but i need adding line to disable macro if col h="" and if any cell contain data in col h then run the macro i try adding it but not success my attempt colored by red i need advise from anybody can help me
thanks
this code works but i need adding line to disable macro if col h="" and if any cell contain data in col h then run the macro i try adding it but not success my attempt colored by red i need advise from anybody can help me
VBA Code:
Sub MoveRows()
Application.ScreenUpdating = False
Dim LastRow As Long, srcWS As Worksheet, desWS As Worksheet
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Set srcWS = Sheets("Data")
Set desWS = Sheets("Moved")
With srcWS
[B][COLOR=rgb(226, 80, 65)]If .Columns(8).Value = "" Then[/COLOR][/B]
Exit Sub
else
.Cells(1, 1).CurrentRegion.AutoFilter 8, "moved"
.AutoFilter.Range.Offset(1).Copy desWS.Cells(desWS.Rows.Count, "A").End(xlUp).Offset(1)
.AutoFilter.Range.Offset(1).EntireRow.Delete
.Range("A1").AutoFilter
End If
End With
Application.ScreenUpdating = True
End Sub