PDA

View Full Version : Solved: Make code more efficient



kathyb0527
09-03-2008, 10:27 AM
I have written the following code. I'm sure there is a more efficient way to do this so the code doesn't have to perform 3 times. Is this a case to use an array or should renaming the range work?

Set rBlanks = wbTarget.ActiveSheet.Range("D2:D" & Range("A" & Rows.Count).End(xlDown).Row)
rBlanks.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Set rBlanks = wbTarget.ActiveSheet.Range("H2:H" & Range("A" & Rows.Count).End(xlDown).Row)
rBlanks.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Set rBlanks = wbTarget.ActiveSheet.Range("i2:i" & Range("A" & Rows.Count).End(xlDown).Row)
rBlanks.SpecialCells(xlCellTypeBlanks).EntireRow.Delete

Thanks for your help once again!

Bob Phillips
09-03-2008, 10:42 AM
I would have thought that was pretty efficient. But is the code right, you want to delete the row if ANY of D, H or I is blank?

kathyb0527
09-03-2008, 12:01 PM
The code is right. I am just suspect of doing the same thing multiple times to different ranges.

:sleuth: