Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel- VBA help on macros that size columns and rows

Posted on 2016-11-21
7
Medium Priority
?
62 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 35

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 23

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 23

Accepted Solution

by:
Ejgil Hedegaard earned 2000 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 23

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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