ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Two Macros from Same Button (https://www.excelbanter.com/excel-programming/383845-run-two-macros-same-button.html)

Exceller

Run Two Macros from Same Button
 
I've searched the archives here but have not found a suitable answer for this.
I want to be able to execute two commands from the same button.
When the button is pressed once Columns B:D are hidden and when the button
is pressed again Columns B:D are unhidden.

Here's the basic macro I've recorded.

Columns("B:D").Select
Selection.EntireColumn.Hidden = True
End Sub

Columns("B:D").Select
Selection.EntireColumn.Hidden = False
End Sub

Any help would be much appreciated.

Thank you.


Jim Thomlinson

Run Two Macros from Same Button
 
The whole thing can be cone with this one line of code...

Columns("B:D").EntireColumn.Hidden = Not Columns("B:D").EntireColumn.Hidden
--
HTH...

Jim Thomlinson


"Exceller" wrote:

I've searched the archives here but have not found a suitable answer for this.
I want to be able to execute two commands from the same button.
When the button is pressed once Columns B:D are hidden and when the button
is pressed again Columns B:D are unhidden.

Here's the basic macro I've recorded.

Columns("B:D").Select
Selection.EntireColumn.Hidden = True
End Sub

Columns("B:D").Select
Selection.EntireColumn.Hidden = False
End Sub

Any help would be much appreciated.

Thank you.


Chip Pearson

Run Two Macros from Same Button
 
You need only a single procedure.

Sub SwitchView()
With ActiveSheet.Range("B:D").EntireColumn
.Hidden = Not .Hidden
End With
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Exceller" wrote in message
...
I've searched the archives here but have not found a suitable answer for
this.
I want to be able to execute two commands from the same button.
When the button is pressed once Columns B:D are hidden and when the button
is pressed again Columns B:D are unhidden.

Here's the basic macro I've recorded.

Columns("B:D").Select
Selection.EntireColumn.Hidden = True
End Sub

Columns("B:D").Select
Selection.EntireColumn.Hidden = False
End Sub

Any help would be much appreciated.

Thank you.




Exceller

Run Two Macros from Same Button
 
Thank you, Jim. It works perfectly. And I'm using it in another workbook as
well!
Regards,
Exceller

"Jim Thomlinson" wrote:

The whole thing can be cone with this one line of code...

Columns("B:D").EntireColumn.Hidden = Not Columns("B:D").EntireColumn.Hidden
--
HTH...

Jim Thomlinson


"Exceller" wrote:

I've searched the archives here but have not found a suitable answer for this.
I want to be able to execute two commands from the same button.
When the button is pressed once Columns B:D are hidden and when the button
is pressed again Columns B:D are unhidden.

Here's the basic macro I've recorded.

Columns("B:D").Select
Selection.EntireColumn.Hidden = True
End Sub

Columns("B:D").Select
Selection.EntireColumn.Hidden = False
End Sub

Any help would be much appreciated.

Thank you.


Exceller

Run Two Macros from Same Button
 
Holy crap--the legend himself--it's ExcElvis--I'm honored! Thanks for the
code.
I've turned on probably 100 of my colleagues to your Excel page. It's the
first resource I turn to for formula/function examples and ideas.
Thanks!
Exceller

"Chip Pearson" wrote:

You need only a single procedure.

Sub SwitchView()
With ActiveSheet.Range("B:D").EntireColumn
.Hidden = Not .Hidden
End With
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Exceller" wrote in message
...
I've searched the archives here but have not found a suitable answer for
this.
I want to be able to execute two commands from the same button.
When the button is pressed once Columns B:D are hidden and when the button
is pressed again Columns B:D are unhidden.

Here's the basic macro I've recorded.

Columns("B:D").Select
Selection.EntireColumn.Hidden = True
End Sub

Columns("B:D").Select
Selection.EntireColumn.Hidden = False
End Sub

Any help would be much appreciated.

Thank you.





Chip Pearson

Run Two Macros from Same Button
 
it's ExcElvis--

That's good. I laughed out loud when I read that.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Exceller" wrote in message
...
Holy crap--the legend himself--it's ExcElvis--I'm honored! Thanks for the
code.
I've turned on probably 100 of my colleagues to your Excel page. It's the
first resource I turn to for formula/function examples and ideas.
Thanks!
Exceller

"Chip Pearson" wrote:

You need only a single procedure.

Sub SwitchView()
With ActiveSheet.Range("B:D").EntireColumn
.Hidden = Not .Hidden
End With
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Exceller" wrote in message
...
I've searched the archives here but have not found a suitable answer
for
this.
I want to be able to execute two commands from the same button.
When the button is pressed once Columns B:D are hidden and when the
button
is pressed again Columns B:D are unhidden.

Here's the basic macro I've recorded.

Columns("B:D").Select
Selection.EntireColumn.Hidden = True
End Sub

Columns("B:D").Select
Selection.EntireColumn.Hidden = False
End Sub

Any help would be much appreciated.

Thank you.







Exceller

Run Two Macros from Same Button
 
That's you, dude. That's what I call you around here.
When my MBA/CPA boss comes to me with an Excel problem (because he knows
less about Excel than my 8 year old) I say "what does ExcElvis have to say
about this..." I go to www.cpearson.com and BINGO! It's there.
If it weren't for you, everyone around here would know I'm incompetent.
Have a good one.
Exceller

"Chip Pearson" wrote:

it's ExcElvis--


That's good. I laughed out loud when I read that.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Exceller" wrote in message
...
Holy crap--the legend himself--it's ExcElvis--I'm honored! Thanks for the
code.
I've turned on probably 100 of my colleagues to your Excel page. It's the
first resource I turn to for formula/function examples and ideas.
Thanks!
Exceller

"Chip Pearson" wrote:

You need only a single procedure.

Sub SwitchView()
With ActiveSheet.Range("B:D").EntireColumn
.Hidden = Not .Hidden
End With
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Exceller" wrote in message
...
I've searched the archives here but have not found a suitable answer
for
this.
I want to be able to execute two commands from the same button.
When the button is pressed once Columns B:D are hidden and when the
button
is pressed again Columns B:D are unhidden.

Here's the basic macro I've recorded.

Columns("B:D").Select
Selection.EntireColumn.Hidden = True
End Sub

Columns("B:D").Select
Selection.EntireColumn.Hidden = False
End Sub

Any help would be much appreciated.

Thank you.









All times are GMT +1. The time now is 12:38 PM.

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