Solved

Excel- VBA help on macros that size columns and rows

Posted on 2016-11-21
7
21 Views
Last Modified: 2016-11-22
I have a sheet that has 2 sets of buttons.

style#1  buttons:
Sizes the rows and columns and hides unneeded columns
Then second button resets the sheet back to normal

Style#2 buttons:
Hides certain columns
The second button resets the sheet back to normal

The problem is, style one will keep sizing rows and columns every time you push the button.
If you reset style 1 it will also keep resizing and resizing if the button is hit twice.

If the (style #1 or style #2 is pressed) then only the reset button for that should be pushed.

I think if a style button is pressed, the only other button that can be pressed should be the reset button for that style

Once the sheet has been reset then you should not be able to reset more, because it will keep shrinking row heights and column widths

Thanks
-Dummy.xlsm
0
Comment
Question by:chris pike
  • 3
  • 3
7 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 41896354
Can't you disable the relevant buttons when one of the 'style' buttons has been clicked and the changes have been made?

You can enable them again when the relevant 'reset' button has been clicked.
0
 

Author Comment

by:chris pike
ID: 41896381
Noire,
Thanks for the comment.

Right now the buttons are shapes that have a macro tied to them.
If I Knew how to disable, I would probably do that.
I have no Idea how to put that into this workbook.

Any help would be appreciated.
Thanks
Chris
0
 
LVL 21

Expert Comment

by:Ejgil Hedegaard
ID: 41896628
One way is to make a variable on module level to remember when the style is set.
And reset on the other button.
That will prevent Style set, or Style reset to run more than once.
See workbook.
--Dummy-1.xlsm
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:chris pike
ID: 41896663
Ejgil,
We are getting close...
After you push style #1 or style #2 the only button that should work is the reset for that style #.

I just pushed Style #2 and then pushed style #1 and the format for the sheet was all messed up. ie wrong column widths.
Thanks
Chris
I have attached Dummy2 it has all the correct column widths...
---Dummy-2.xlsm
0
 
LVL 21

Accepted Solution

by:
Ejgil Hedegaard earned 500 total points
ID: 41896702
A few more conditions will do that.
----Dummy-2.xlsm
0
 

Author Closing Comment

by:chris pike
ID: 41897572
Thanks Ejgil
You are a wizard.....
Nicely done.
Appreciate your expertize

Can you take a moment and explain how we were able to disable the other buttons that we didn't want to be pressed?
0
 
LVL 21

Expert Comment

by:Ejgil Hedegaard
ID: 41897608
There are 2 boolean variables, Style1Set and Style2Set.
The 2 macros Batching (Style1) and Packaging Style2) must run when nothing has run, both variables are False.
In each the appropriate button is set to True, allowing only the reset for that to run.
Set up in a table it looks like this.

Macro button              Style1Set                 Style2Set          
Style #1                  False                     False              
Style #1 Reset            True                      False              
Style #2                  False                     False              
Style #s Reset            False                     True
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now