Help with macro - deja vu

D

DA

Somebody helped me build the short macro below which, I am pretty
sure, worked in an old file. I copied it into a new file and it is
crashing on the 4th command. runtime error 1004

I have no recollection of what

Selection.SpecialCells(xlCellTypeFormulas, 16).Select

does!

I have range-named a row "test.hide.column.by.DA" with some empty
entries at the left and right but, in the middle, it has cells with
either the number 1 or the text #N/A in them. My recollection is that
it is supposed to hide every column that has the #N/A result in it.
Can anyone help me figure out what is wrong. I don't see any cell
comments.

Sub hideColumns()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
Application.Goto Reference:="test.hide.column.by.DA"
Selection.SpecialCells(xlCellTypeFormulas, 16).Select
'if the macro bombs at the line below, it may be due to cell
comments!!, see 09-07-06 newsgroup post
Selection.EntireColumn.Hidden = True

'this protects but allows column and row width changes
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True

Application.ScreenUpdating = True
Range("a2").Select
End Sub
 
D

DA

Ok, I think I figured it out. It looks like it would need to be a
real #N/A, not just a text string.

Never mind but thanks!
D
 
D

Dave Peterson

You specifically looked through formulas by using: xlCellTypeFormulas

xlcelltypeconstants
would have been my next try.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top