Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I recorded a macro by selecting a bunch of worksheets, then selecting a range
of rows, then going to the format menu and selecting column hide. When I carry out this procedure by hand it works fine, but when I run the macro, it only hides the rows in the first worksheet. Anyone know why or what I might be doing wrong. Thanks! |
#2
![]() |
|||
|
|||
![]()
Sandy,
You could try adding the following code into your macro: Dim Sheetnumber Sheetnumber = 1 Do "INSERT EXISTING MACRO CODE HERE" Sheetnumber = Sheetnumber + 1 Loop Until Sheetnumber = ActiveWorkbook.Worksheets.Count This code will run the code on each sheet in the active workbook. "SandyR" wrote: I recorded a macro by selecting a bunch of worksheets, then selecting a range of rows, then going to the format menu and selecting column hide. When I carry out this procedure by hand it works fine, but when I run the macro, it only hides the rows in the first worksheet. Anyone know why or what I might be doing wrong. Thanks! |
#3
![]() |
|||
|
|||
![]()
That seems like a good work around, and I will probably use it, but I would
like to understand why this doesn't work as is. I am still trying to understand the underlying principles of this object oriented stuff. "Aussie CPA" wrote: Sandy, You could try adding the following code into your macro: Dim Sheetnumber Sheetnumber = 1 Do "INSERT EXISTING MACRO CODE HERE" Sheetnumber = Sheetnumber + 1 Loop Until Sheetnumber = ActiveWorkbook.Worksheets.Count This code will run the code on each sheet in the active workbook. "SandyR" wrote: I recorded a macro by selecting a bunch of worksheets, then selecting a range of rows, then going to the format menu and selecting column hide. When I carry out this procedure by hand it works fine, but when I run the macro, it only hides the rows in the first worksheet. Anyone know why or what I might be doing wrong. Thanks! |
#4
![]() |
|||
|
|||
![]()
Post your code so someone can look at it.
"SandyR" wrote in message ... I recorded a macro by selecting a bunch of worksheets, then selecting a range of rows, then going to the format menu and selecting column hide. When I carry out this procedure by hand it works fine, but when I run the macro, it only hides the rows in the first worksheet. Anyone know why or what I might be doing wrong. Thanks! |
#5
![]() |
|||
|
|||
![]()
Here is one of my attempts. Note that there are other worksheets in the
workbook that are not selected, and that the range and clear statements work for all the selected worksheets: Sub setup() ' ' setup Macro ' Macro recorded 9/28/2005 by SR ' ' Keyboard Shortcut: Ctrl+Shift+S ' Sheets(Array("0110", "0120", "0130", "0141", "0142", "0143", "0144", "0145", "0146", _ "0147", "0160", "0170")).Select Sheets("0110").Activate Columns("A:AB").Select Selection.EntireColumn.Hidden = False Rows("1:55").Select Selection.EntireRow.Hidden = False ' Clear values in estimated total expenditure, level A, level B, department request ' manager reccomend and council approved columns Range("K8:K15").Select Selection.ClearContents . . . (more select and clear statements) Rows("28:36").Select Selection.EntireRow.Hidden = True "SandyR" wrote: I recorded a macro by selecting a bunch of worksheets, then selecting a range of rows, then going to the format menu and selecting column hide. When I carry out this procedure by hand it works fine, but when I run the macro, it only hides the rows in the first worksheet. Anyone know why or what I might be doing wrong. Thanks! |
#6
![]() |
|||
|
|||
![]()
Sorry Sandy,
It looks like VBA does not work with grouped worksheets. See Tom's reply below: ---------------------------------------------------------------------------------- for the most part, VBA does not support actions performed on grouped sheets. In some cases, you can work around it by using Selection, but it appears that is not the case for you. Just loop through the sheets and perform the action. -- Regards, Tom Ogilvy "PCLIVE" wrote in message ... I saw another post regarding problems with hiding columns using a macro. I run the macro recorder, group several sheets together, and then select multiple columns on the sheet. Goto format and select the option to columns, hide. I stop the macro recorder. When checking each of the sheets that were grouped together, the selected columns on each worksheet has been hidden. That is what I want. If I unhide everything and then run the macro I just recorded, it only hides the columns on the active sheet. Does anyone know why this is happening and how I can get it to the same columns on all of the grouped sheets, just as if I was doing it manually. This is what gets recorded my the macro recorder. Rows("1:17").Select Sheets(Array("Sheet2", "Sheet3", "Sheet4")).Select Sheets("Sheet4").Activate Selection.EntireRow.Hidden = True Rows("25:39").Select Selection.EntireRow.Hidden = True Columns("B:F").Select Range("B18").Activate Selection.EntireColumn.Hidden = True Thanks, Paul "SandyR" wrote in message ... Here is one of my attempts. Note that there are other worksheets in the workbook that are not selected, and that the range and clear statements work for all the selected worksheets: Sub setup() ' ' setup Macro ' Macro recorded 9/28/2005 by SR ' ' Keyboard Shortcut: Ctrl+Shift+S ' Sheets(Array("0110", "0120", "0130", "0141", "0142", "0143", "0144", "0145", "0146", _ "0147", "0160", "0170")).Select Sheets("0110").Activate Columns("A:AB").Select Selection.EntireColumn.Hidden = False Rows("1:55").Select Selection.EntireRow.Hidden = False ' Clear values in estimated total expenditure, level A, level B, department request ' manager reccomend and council approved columns Range("K8:K15").Select Selection.ClearContents . . . (more select and clear statements) Rows("28:36").Select Selection.EntireRow.Hidden = True "SandyR" wrote: I recorded a macro by selecting a bunch of worksheets, then selecting a range of rows, then going to the format menu and selecting column hide. When I carry out this procedure by hand it works fine, but when I run the macro, it only hides the rows in the first worksheet. Anyone know why or what I might be doing wrong. Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
hide a worksheet so that a macro can still find it | Excel Worksheet Functions | |||
hide rows with macro | Excel Discussion (Misc queries) | |||
Button fails to call macro when open an Excel via Intranet | Excel Discussion (Misc queries) | |||
.ONACTION macro call fails | Excel Discussion (Misc queries) | |||
HELP! How do you--> Lock a set of rows but also link worksheets to | Excel Discussion (Misc queries) |