sous2817
Well-known Member
- Joined
- Feb 22, 2008
- Messages
- 2,276
Hello everyone,
Currently I'm using:
to delete all of the resulting "#N/A"s from my formula. It works fine except it deletes the entire row and not just the area between .Range("A1:D" & lr). Am I missing something, or can someone help me tweak the code so that it only deletes the within the area and not the whole row.
Thanks in advance!
Currently I'm using:
Code:
lr = .Range("C" & Rows.Count).End(xlUp).Row
If lr = 1 Then lr = 2
Set rng = .Range("A1:D" & lr)
.Range("B2:B" & lr).Formula = "=IF(A2="""",VLOOKUP(C2,$G$2:$H$" & lr2 & ",2,0),VLOOKUP(A2,$G$2:$H$" & lr2 & ",2,0))"
.Range("B2:B" & lr).Calculate
.Range("B2:B" & lr).Value = .Range("B2:B" & lr).Value
With rng
.AutoFilter Field:=2, Criteria1:="#N/A"
'assume the first row had headers
On Error Resume Next
.Offset(1, 0).Resize(.Rows.Count - 1, 1). _
SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp
On Error GoTo 0
'remove the autofilter
.AutoFilter
End With
to delete all of the resulting "#N/A"s from my formula. It works fine except it deletes the entire row and not just the area between .Range("A1:D" & lr). Am I missing something, or can someone help me tweak the code so that it only deletes the within the area and not the whole row.
Thanks in advance!