Hide / Unhide Buttons with the help of a code
- RAJESH SHAH
- Thread is marked as Resolved.
-
-
Mumps thanks for responding. I tried your code, But still the buttons are not interchanging. It is displaying an error in both the codes like in the image. I have just placed the buttons on one on top of the other. Do You think I should group them.?
-
Please attach a copy of your actual file including all your macros.
-
I will share it sometime. Please don't laugh at my codes and presentation. I am a beginner and try all sorts of different things. Please note the code is running perfectly. Only thing is to display one button only at a time. Each code takes more than 2 minutes to run in my system. If done in the server it may take at least 1/2 hour to run.
-
This is the workbook I am sharing.
-
-
If I place the buttons on top of one another, a menu is activated by the name of Shape format. There is an option in that you can interchange the buttons like Bring forward and Send backward. But to use that function in a code I have no knowledge of it.
-
Mumps. Your code was right. Instead of button I changed it to the name of the button. That is why it was not accepting. So I recorded a macro and tried it your way and found it working. Thanks a lot. The problem now is solved.
{ActiveSheet.Shapes.Range(Array("Button 3")).Select
ActiveSheet.Shapes("Button 3").ZOrder msoSendBackward
Range("K6").Select}
ActiveSheet.Shapes.Range(Array("Button 5")).Select
ActiveSheet.Shapes("Button 5").ZOrder msoSendBackward
Range("K7").Select
-
Mumps. Your code was right. Instead of button I changed it to the name of the button. That is why it was not accepting. So I recorded a macro and tried it your way and found it working. Thanks a lot. The problem now is solved.
</>ActiveSheet.Shapes.Range(Array("Button 3")).Select
ActiveSheet.Shapes("Button 3").ZOrder msoSendBackward
Range("K6").Select}
ActiveSheet.Shapes.Range(Array("Button 5")).Select
ActiveSheet.Shapes("Button 5").ZOrder msoSendBackward
Range("K7").Select</>
-
READ THE FORUM RULES THEM MESSAGE ME TO LET ME KNOW THAT YOU WILL FOLLOW THEM.
QuoteWelcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post
All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.
How to use code tags
Just highlight all of the code and press the <> in the post menu above button to add the code tags.
Thanks.
I don't understand why you need two buttons.
The next time you post make sure that you follow our Rules or else your post will be closed.
-
I have copied and saved the rules of this forum on my desktop. In future, before posting, I will make sure that the rules are followed.
I would like to know how to close my query once it is solved.
-
-
I'm glad everything worked out.
Just a comment about your code: Recording a macro is a good start but most often the result is not very efficient. To give you an example, you don't very often need to select a cell or a range to perform an action on it.
for example, this code:
CodeWith Sheets("Original").Select Columns("A:I").Select Selection.Copy Range("A2").Select Sheets("Bank").Select Range("A1").Select ActiveSheet.Paste End With
can be written like this:
or:
can be written like this:
This would speed up the macro and make it much shorter. There are other things you could do to improve the code efficiency. Do a little research in what can be done to make a macro run more quickly. I'm sure you will find many such methods.
-
Thank you so much Mumps. That was very kind of you. There is no end to learning in excel especially. So, whatever is related to accounts, I really try and learn the formulas and codes connected to it. Your words are encouraging and I need that inspiration. Thank you once again.
-
You are very welcome.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!