Check values in each column
Martin
--you can either you Worksheetfunction.ISNA() as suggested by OssieMac or
use .Text property of range to check NA() s as below.
--You can use the .End(xlToLeft) to determin the last column in that row
with any data.This way you can avoid unnecessary loops..
Dim lngCol As Long
For lngCol = Cells(2, Columns.Count).End(xlToLeft).Column To 1 Step -1
If Cells(2, lngCol).Text = "#N/A" Then Columns(lngCol).Delete
Next
If this post helps click Yes
---------------
Jacob Skaria
"Martin" wrote:
Hi
I want to check the value of row 2 in each column and if it = "#N/A" then
delete the column. I have got this far but it doesn't wuite work. Can
anyone help?
For iColumn = 1 To 256
If Cells(2, iColumn).Value = "#N/A" Then
Columns(iColumn).EntireColumn.Delete
Next iColumn
Thanks in advance
|