Hi all,
I am using VBA to construct a spreadsheet for a user to analyse data. The user pastes data exported from two host systems, and I build formulae to harmonise the data (date formats, etc.). In one sheet I create vlookup formulae between the two sheets, and there are always a lot of #N/As. I would like to give the user the option to delete these rows, but I can't seem to trap these.
Some sample code:
Sub FormatSheet()
Application.ScreenUpdating = False
Dim rng As Range, rng2 As Range
Dim lastrow As Long
Set rng = Range("D65536").End(xlUp)
Do Until rng.Row = 5
Set rng2 = rng.Offset(-1)
If rng.Offset(0, 7) = "#N/A" Then rng.EntireRow.Delete
Set rng = rng2
Loop
End sub
I've tried all sorts of weird constructs using Iserror, but all to no avail.
As always, any help will be greatly appreciated,
hh
I am using VBA to construct a spreadsheet for a user to analyse data. The user pastes data exported from two host systems, and I build formulae to harmonise the data (date formats, etc.). In one sheet I create vlookup formulae between the two sheets, and there are always a lot of #N/As. I would like to give the user the option to delete these rows, but I can't seem to trap these.
Some sample code:
Sub FormatSheet()
Application.ScreenUpdating = False
Dim rng As Range, rng2 As Range
Dim lastrow As Long
Set rng = Range("D65536").End(xlUp)
Do Until rng.Row = 5
Set rng2 = rng.Offset(-1)
If rng.Offset(0, 7) = "#N/A" Then rng.EntireRow.Delete
Set rng = rng2
Loop
End sub
I've tried all sorts of weird constructs using Iserror, but all to no avail.
As always, any help will be greatly appreciated,
hh