Trying to minimise my code

TonyUK72

Board Regular
Joined
Oct 6, 2015
Messages
220
Code:
    ActiveSheet.Shapes("Q1A1").Select
    With Selection
        .Value = xlOff
        .LinkedCell = "Result_DataLISTS!$C$1"
        .Display3DShading = False
    End With
    ActiveSheet.Shapes("Q1A2").Select
    With Selection
        .Value = xlOff
        .LinkedCell = "Result_DataLISTS!$C$1"
        .Display3DShading = False
    End With
    ActiveSheet.Shapes("Q1A3").Select
    With Selection
        .Value = xlOff
        .LinkedCell = "Result_DataLISTS!$C$1"
        .Display3DShading = False
    End With
    ActiveSheet.Shapes("Q1A4").Select
    With Selection
        .Value = xlOff
        .LinkedCell = "Result_DataLISTS!$C$1"
        .Display3DShading = False
    End With

I have the above code, that essentially needs to be repeated 18 times. "Q1A1", "Q1A2", "Q1A3", "Q1A4" and $C$1 would become "Q2A1", "Q2A2", "Q2A3", "Q2A4" and $C$2 and so on.

Whilst I have used Dim, For and Next for ranges, using the same code for Active.Shapes seems to fail. Is this doable or do I need to have a bulk of code?

Thanks in advance.
 
needs to be repeated 18 times. "Q1A1", "Q1A2", "Q1A3", "Q1A4" and $C$1 would become "Q2A1", "Q2A2", "Q2A3", "Q2A4" and $C$2 and so on.
has now become
The spreadsheet has 18 "Group Boxes" each "Group Box" is essentially a Multiple Choice Question, that has four answers, each possible answer is a "Radio Button". So your solution above clears the first 18 "Radio Buttons" from the first 4 "Group Boxes".


If you want to clear all buttons at once try this one liner
Code:
ActiveSheet.OptionButtons = False
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,225,761
Messages
6,186,893
Members
453,383
Latest member
SSXP

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top