M
macrolad
Greetings all, first timer here.
Need some help trying to get my first processor built using VBA in
Excel.
Trying to get two formulas to work but having some difficulty.
First, trying to get VBA to search the open worksheet and if the sum of
two cells in two different columns equals the number in a 3rd column,
then delete row.
Second, a simple if then statement of deleting duplicate rows. Here is
what I have but it doesn't work. The data is all in column 1.
Public Sub Format(wb As Workbook)
Dim rngRow As Range
Dim lngRows As Long
Dim lngCurRow As Long
Dim rngTable As Range
Set rngTable = wb.Worksheets(1).Cells(1).CurrentRegion
lngRows = rngTable.Rows.Count
For lngCurRow = lngRows To 2 Step -1
Set rngRow = rngTable.Rows(lngCurRow)
If rngRow.Cells("Booking") = rngRow.Cells("Booking").Offset(-1, 0)
Then rngRow.EntireRow.Delete
End If
Next
Set rngTable = wb.Worksheets(1).Cells(1).CurrentRegion
lngRows = rngTable.Rows.Count
If anyone can assist it would be greatly appreciated.
Need some help trying to get my first processor built using VBA in
Excel.
Trying to get two formulas to work but having some difficulty.
First, trying to get VBA to search the open worksheet and if the sum of
two cells in two different columns equals the number in a 3rd column,
then delete row.
Second, a simple if then statement of deleting duplicate rows. Here is
what I have but it doesn't work. The data is all in column 1.
Public Sub Format(wb As Workbook)
Dim rngRow As Range
Dim lngRows As Long
Dim lngCurRow As Long
Dim rngTable As Range
Set rngTable = wb.Worksheets(1).Cells(1).CurrentRegion
lngRows = rngTable.Rows.Count
For lngCurRow = lngRows To 2 Step -1
Set rngRow = rngTable.Rows(lngCurRow)
If rngRow.Cells("Booking") = rngRow.Cells("Booking").Offset(-1, 0)
Then rngRow.EntireRow.Delete
End If
Next
Set rngTable = wb.Worksheets(1).Cells(1).CurrentRegion
lngRows = rngTable.Rows.Count
If anyone can assist it would be greatly appreciated.