ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   new macro to format worksheet (https://www.excelbanter.com/excel-worksheet-functions/228040-new-macro-format-worksheet.html)

mclovin

new macro to format worksheet
 
I'm trying to record a new macro to hide specific columns & rows. I went to
"record new macro" and went through the steps, but when I try to test out the
macro I recorded, it ends up hiding more columns than I wanted. For
instance, I want to hide H:I, K:M, S:AE & AG:AH, but when I play the macro it
ends up hiding F:BC. How do I fix that?

Luke M

new macro to format worksheet
 
It may depend on how you recorded it, what order you selected things, etc.

Correction:
Open the VBA (Alt+F11), open the module you're macro is reocrded in.
whatever part is there dealing with hiding the columns can be deleted and
replaced with this single line:

Range("H:I,K:M,S:AE,AG:AH").EntireColumn.Hidden = True

Of note, rows can be done with something like
Range("5:6,10:11")EntireRow.Hidden = True
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"mclovin" wrote:

I'm trying to record a new macro to hide specific columns & rows. I went to
"record new macro" and went through the steps, but when I try to test out the
macro I recorded, it ends up hiding more columns than I wanted. For
instance, I want to hide H:I, K:M, S:AE & AG:AH, but when I play the macro it
ends up hiding F:BC. How do I fix that?


mclovin

new macro to format worksheet
 
It didn't work. Perhaps I deleted too much??
So in my module, it says:

Range("H:I,K:M,S:AE,AG:AH").EntireColumn.Hidden = True

End Sub


"Luke M" wrote:

It may depend on how you recorded it, what order you selected things, etc.

Correction:
Open the VBA (Alt+F11), open the module you're macro is reocrded in.
whatever part is there dealing with hiding the columns can be deleted and
replaced with this single line:

Range("H:I,K:M,S:AE,AG:AH").EntireColumn.Hidden = True

Of note, rows can be done with something like
Range("5:6,10:11")EntireRow.Hidden = True
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"mclovin" wrote:

I'm trying to record a new macro to hide specific columns & rows. I went to
"record new macro" and went through the steps, but when I try to test out the
macro I recorded, it ends up hiding more columns than I wanted. For
instance, I want to hide H:I, K:M, S:AE & AG:AH, but when I play the macro it
ends up hiding F:BC. How do I fix that?



All times are GMT +1. The time now is 08:22 AM.

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