ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with macro - deja vu (https://www.excelbanter.com/excel-programming/430769-help-macro-deja-vu.html)

DA[_2_]

Help with macro - deja vu
 
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

DA[_2_]

Help with macro - deja vu
 
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


Dave Peterson

Help with macro - deja vu
 

You specifically looked through formulas by using: xlCellTypeFormulas

xlcelltypeconstants
would have been my next try.

DA wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com