You might also put in an ON ERROR RESUME NEXT just in case there aren't any blanks.If the cells are actually blank, rather than a formula showing "" try
Code:Range("D2", Range("D" & Rows.Count).End(xlUp)).SpecialCells(xlBlanks).Offset(, -2).Resize(, 2).Clear[U][COLOR=#0000cd]Contents[/COLOR][/U]
You might also put in an ON ERROR RESUME NEXT just in case there aren't any blanks.
On Error Resume Next
Range("D2", Range("D" & Rows.Count).End(xlUp)).SpecialCells(xlBlanks).Offset(, -2).Resize(, 2).ClearContents
On Error GoTo 0
Excellent point Greg, this will now beCode:On Error Resume Next Range("D2", Range("D" & Rows.Count).End(xlUp)).SpecialCells(xlBlanks).Offset(, -2).Resize(, 2).ClearContents On Error GoTo 0
Sub aTest()
Dim LastRow As Long
With Sheets("Sheet1")
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
.Range("B2:C" & LastRow).Value = _
.Evaluate("=IF(D2:D" & LastRow & "="""","""",C2:B" & LastRow & ")")
End With
End Sub
Fluff's (and Marcelo's for that matter) should work on non-contiguous ranges. You wouldn't need autofilter in order to pull this off.I should have mentioned that the blank cells in Column "D" will not be contiguous. Is there a way to do this with Autofilter instead of For Next Loop?