Help for Macro to Fill Columns Based on Tick Boxes
Hello everyone,
I need some help. I have tried to make a Macro, but it doesn't work as I want. I have put A link to the file below this message.
What i wish is, when I press on the "A" box, the A column stay note filled whith black, and the other column (C5 to F14) are filled whith black. When I press again "A" the spreadsheet reset.
When I press A and B, the column A and B stay note filled whith black, and the other column (D5 to F14). When I press C and D, the column C and D stay note filled whith black, and the other column (B5 to C14 and E5 to F14).
I hope that you have understand my post (Sorry i'm French)
MS 365 Subscription Insider Beta Channel (Windows 11 64-bit)
Posts
62,024
Re: Help for Macro
Welcome to the forum.
There are instructions at the top of the page explaining how to attach your sample workbook.
Ali Enthusiastic self-taught user of MS Excel who's always learning! Don't forget to say "thank you" to anyone who has offered you help in your thread. You can reward them by clicking on * Add Reputation below theur user name on the left, if you wish.
Forum Rules (updated September 2018): please read them here.
How to use the Power Query code you've been given: help here. More about the Power suite here.
With a well designed worksheet it may need a single tiny procedure for all the check boxes !
So in order to do it you must execute the UsageUnique procedure just once then enjoy !
If it's the expected result, Module1 is useless, to be deleted …
According to your attachment as a VBA beginner starter to paste to the Feuil1 worksheet module :
PHP Code:
Sub BlackWhite(N&)
A$ = Choose(N, "B5:B7,B9:B14", "C5:C6,C8:C12,C14", "D5:D10,D12:D14", "E5,E7:E14", "F6:F9,F11:F14")
Range(A).Interior.ColorIndex = 1 + (Shapes("Coche" & N).ControlFormat.Value = 1)
End Sub
Private Sub UsageUnique()
For N& = 1 To Shapes.Count
With Shapes(N)
.Name = "Coche" & N
.OnAction = "'Feuil1.BlackWhite " & N & "'"
End With
BlackWhite N
Next
End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Last edited by Marc L; 04-04-2021 at 09:09 AM.
Reason: typo …
With a well designed worksheet it may need a single tiny procedure for all the check boxes !
So in order to do it you must execute the UsageUnique procedure just once then enjoy !
If it's the expected result, Module1 is useless, to be deleted …
According to your attachment as a VBA beginner starter to paste to the Feuil1 worksheet module :
PHP Code:
Sub BlackWhite(N&)
A$ = Choose(N, "B5:B7,B9:B14", "C5:C6,C8:C12,C14", "D5:D10,D12:D14", "E5,E7:E14", "F6:F9,F11:F14")
Range(A).Interior.ColorIndex = 1 + (Shapes("Coche" & N).ControlFormat.Value = 1)
End Sub
Private Sub UsageUnique()
For N& = 1 To Shapes.Count
With Shapes(N)
.Name = "Coche" & N
.OnAction = "'Feuil1.BlackWhite " & N & "'"
End With
BlackWhite N
Next
End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Bookmarks