Macro to hide / un-hide #/NA

cuda8630

New Member
Joined
Feb 25, 2013
Messages
4
I have a summary tab that is populated by Vlookups off of the other tabs in the workbook.

I would like to create a sort of "refresh" macro that will allow the user to click the button which would then unhide all cells and then hide only cells that contain a #N/A returned from the vlookup in column D after updates are made on the other tabs.

Any ideas would be helpful...

Thanks!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Welcome to the board.

Try this
Code:
Sub Macro1()
Columns("B:B").EntireRow.Hidden = False
On Error Resume Next
Columns("B:B").SpecialCells(xlCellTypeFormulas, 16).EntireRow.Hidden = True
On Error GoTo 0
End Sub
 
Upvote 0
Try this
Rich (BB code):
Sub Macro1()
Columns("B:B").EntireRow.Hidden = False
On Error Resume Next
Columns("B:B").SpecialCells(xlCellTypeFormulas, 16).EntireRow.Hidden = True
On Error GoTo 0
End Sub
Why not use the defined VB constant in place of the "magic number" 16 (I think if would be more self-documenting)?

Columns("B:B").SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Hidden = True
 
Upvote 0
Why not use the defined VB constant in place of the "magic number" 16 (I think if would be more self-documenting)?

Columns("B:B").SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Hidden = True
Because it came from the Macro Recorder.
 
Upvote 0
Because it came from the Macro Recorder.
Ah, that explains it! I have seen others do the same thing and wondered why they would go through the trouble of converting the constant to a numerical value instead of just using the built-in constant directly, especially given that the help files do not even list the numerical equivalents for those constants. I never gave a thought to what the Macro Recorder might be doing if asked to generate the code line.
 
Upvote 0
Ah, that explains it! I have seen others do the same thing and wondered why they would go through the trouble of converting the constant to a numerical value instead of just using the built-in constant directly, especially given that the help files do not even list the numerical equivalents for those constants. I never gave a thought to what the Macro Recorder might be doing if asked to generate the code line.

The macro recorder is such a great tool, and far too often overlooked.
If I don't know the syntax off the top of my head, that is one of my first steps.
 
Upvote 0
The macro recorder is such a great tool, and far too often overlooked.
If I don't know the syntax off the top of my head, that is one of my first steps.
Interesting how different people handle the same situation differently... whenever I am stuck for syntax, I type the keyword somewhere in the VB editor (if it is not already typed in somewhere) and press F1 to get the help files for that keyword and then build the code line from that. I should mention, though, that I always keep an instance of XL2003 loaded for that purpose (as well as to test my code/formulas across multiple versions of Excel) because I find the help files in XL2007 less than useful (XL2010 is a little bit better in that respect, but XL2003's help files are located in the computer so it doesn't have to load a web page like XL2007 and above do).
 
Upvote 0
Interesting how different people handle the same situation differently... whenever I am stuck for syntax, I type the keyword somewhere in the VB editor (if it is not already typed in somewhere) and press F1 to get the help files for that keyword and then build the code line from that. I should mention, though, that I always keep an instance of XL2003 loaded for that purpose (as well as to test my code/formulas across multiple versions of Excel) because I find the help files in XL2007 less than useful (XL2010 is a little bit better in that respect, but XL2003's help files are located in the computer so it doesn't have to load a web page like XL2007 and above do).

Thanks for the help...the code works great with the added button for the user to click...
 
Upvote 0

Forum statistics

Threads
1,203,530
Messages
6,055,936
Members
444,837
Latest member
TheBams

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top