Select and delete range

rhino4eva

Active Member
Joined
Apr 1, 2009
Messages
260
Office Version
  1. 2010
Platform
  1. Windows
Sub adam()

Sheets("Tabulate").UsedRange
LRow = Range("A" & Rows.Count).End(xlUp).Row
Range("c2", "d" & LRow).SpecialCells(xlCellTypeBlanks).Select

End Sub

I use the above code to select blank cells in columns C & D
I am having trouble achieving the next step

I want to delete the row that the selected rows are found in
I cant use entirerow.delete as it interferes with a pivot table yo the right
I just want to delete and shift up the range column A to G that have blank cells all the way down to the LRow
 
Range("A2:G" & lRow).SpecialCells(xlCellTypeBlanks).Delete shift:=xlUp
I don't think I am doing the right thing

Column A is populated but if there is nothing in B C or D then I need to delete ABCDEFG
the CODE above only DELETES BCDEFG and leaves A intact
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I asked you to run a piece of code on it's own & report back.
Can you please do that?
 
Upvote 0
sorry I got a step ahead ....it does nothing as there no blanks in column A

Column A is populated
but if there is nothing in B C or D then I need to delete ABCDEFG
 
Upvote 0
Ok, I got you.
Could you have,say, B5 & D5 blank with C5 having a value.
Also is it ok to delete the entire row?
 
Upvote 0
sorry in the delay but :- yes i could have B5 & D5 blank with C5 having a value.
but I would like to restrict the row to A to G as there is a crucial PIVOT just to right
 
Upvote 0
Ok, how about
Code:
Sub rhino4eva()
   Dim Rng As Range
   
   For Each Rng In Range("B:D").SpecialCells(xlBlanks).Areas
      Intersect(Rng.EntireRow, Range("A:G")).Delete
   Next Rng
End Sub
 
Upvote 0
fantastic its just what I needed ... I didn't know you could limit delete.entirerow
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

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