Delete rows based on blank cell; then copy formula to an entire column

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
164
Office Version
  1. 365
Platform
  1. Windows
Hi

I am desperately seeking an answer to this issue....

I have the code to erase the blank cells:

VBA Code:
Sub DeleteAllEmptyRows()
  On Error Resume Next
    Sheets("Staffing-Processes").Range("E2:E5000").Select
    Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

First - I would like the code to delete rows in multiple worksheets (all worksheets; 10 of them) are all designed the same

Second - The more pressing issue is that as the rows are deleted but so is the formula located in column AB which is imperative that it remains. This is the formula in column AB: =F2&" / ("&A2&") / "&AA2&" / "&X2 which starts on AB2.

I need to be able to delete rows where the cell in column E is blank but also ensure that the formula located in column AB remains because it is needed for NEW entries at a later date

PLEASE any help would be greatly appreciated.

thank you.
Dan
 
I am using 2016

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
VBA Code:
Sub DeleteAllEmptyRows()
  Dim wb As Workbook, sht As Worksheet, rng As Range, cellx As Range, i As Long
  Set wb = ThisWorkbook
  Set sht = wb.Worksheets("Staffing-Processes")
  Set rng = sht.Range("E2:E5000")
  For i = rng.Rows.Count + 1 To 2 Step -1
    If IsEmpty(rng.Cells(i - 1)) Then
        'Debug.Print rng.Cells(i).Value
        sht.Rows(i).Delete
    End If
Next i
sht.Cells(2, 28).Copy
sht.Range(Cells(3, 28), Cells(5000, 28)).PasteSpecial (xlPasteFormulas)
End Sub
IT WORKED !!!! I really appreciate your help with this
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top