I'm a beginner and your lessons are great, but I have to comment that it's mor efficient for code to avoid .select and selection. as much as possible, in this case you can just type: Cells(xrow, 1).EntireRow.Delete
The problem i am having is that the empty rows i have are zero value based on formula. so , when i ma using the code , its deleting every thing. any advise. My 1st row is row 8 this is the code i am using Sub Delete_Rows() Dim lastrow As Long, xrow As Long xrow = 8
lastrow = Range("a400").End(xlUp).row Do Until xrow = lastrow If Cells(xrow, 8).Value = "" Then Cells(xrow, 8).Select Selection.EntireRow.Delete xrow = xrow - 1 lastrow = lastrow - 1 End If xrow = xrow + 1 Loop End Sub
Hi,I already do as what u writebut error lastrow = Range("A50000").End(x1up).Rowwhat problem,where I do mistake?Sub DeleteBlankRows() Dim lastrow As Long, xrow As Long xrow = 1'finds last cell in column A with data lastrow = Range("A50000").End(x1up).RowDo Until xrow = lastrow If Cells(xrow, 1).Value = "" Then Cells(xrow, 1).Select Selection.EntireRow.Delete xrow = xrow - 1 lastrow = lastrow - 1End If xrow = xrow + 1 LoopEnd Sub
'For deleting blank columns. Sub deleteBlankCoumns() Dim Xcol As Long, LastCol As Long Sheets("Loops").Select Xcol = 1 LastCol = Range("XFD1").End(xlToLeft).Column Do Until Xcol = LastCol If Cells(1, Xcol).Value = "" Then Cells(1, Xcol).Select Selection.EntireColumn.Delete Xcol = Xcol - 1 LastCol = LastCol - 1 End If
Sub delRow() Dim lastRow As Long lastRow = Range("a900000").End(xlUp).Row Do Until lastRow = 1 If Cells(lastRow, 1) = "" Then Rows(lastRow).Delete End If lastRow = lastRow - 1 Loop End Sub
Great Sir....Please keep the code at last in one frame of camera so that we can take picture for our reference and practice it.
This is really great. Thanks. I purchased your excel file. Great stuff.
I'd be more than happy to pay if you teach more advanced courses.
I'm a beginner and your lessons are great, but I have to comment that it's mor efficient for code to avoid .select and selection. as much as possible, in this case you can just type: Cells(xrow, 1).EntireRow.Delete
If I have to search two values and delete them what should I do?
The problem i am having is that the empty rows i have are zero value based on formula.
so , when i ma using the code , its deleting every thing. any advise.
My 1st row is row 8
this is the code i am using
Sub Delete_Rows()
Dim lastrow As Long, xrow As Long
xrow = 8
lastrow = Range("a400").End(xlUp).row
Do Until xrow = lastrow
If Cells(xrow, 8).Value = "" Then
Cells(xrow, 8).Select
Selection.EntireRow.Delete
xrow = xrow - 1
lastrow = lastrow - 1
End If
xrow = xrow + 1
Loop
End Sub
Thank you very much.
Sir, how can I apply it to multiple sheets?
I want to delete 1 Row and 3 Columns only.
Thanks again
Another great video, thanks.
M getting runtime error 1004
I'm getting the same error.. Someone help lol
today i did learn one new think
conditions are not hard, it's those "Objects.operations"(e.g. Cells.Select) that I never seen before.
Thanks a lot!
Hi,I already do as what u writebut error lastrow = Range("A50000").End(x1up).Rowwhat problem,where I do mistake?Sub DeleteBlankRows()
Dim lastrow As Long, xrow As Long
xrow = 1'finds last cell in column A with data
lastrow = Range("A50000").End(x1up).RowDo Until xrow = lastrow If Cells(xrow, 1).Value = "" Then
Cells(xrow, 1).Select
Selection.EntireRow.Delete xrow = xrow - 1
lastrow = lastrow - 1End If
xrow = xrow + 1
LoopEnd Sub
How this is helpful when excel has filter option?
'For deleting blank columns.
Sub deleteBlankCoumns()
Dim Xcol As Long, LastCol As Long
Sheets("Loops").Select
Xcol = 1
LastCol = Range("XFD1").End(xlToLeft).Column
Do Until Xcol = LastCol
If Cells(1, Xcol).Value = "" Then
Cells(1, Xcol).Select
Selection.EntireColumn.Delete
Xcol = Xcol - 1
LastCol = LastCol - 1
End If
Xcol = Xcol + 1
Loop
End Sub
Sub delRow()
Dim lastRow As Long
lastRow = Range("a900000").End(xlUp).Row
Do Until lastRow = 1
If Cells(lastRow, 1) = "" Then
Rows(lastRow).Delete
End If
lastRow = lastRow - 1
Loop
End Sub
Thanks a lot!