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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,222,830
Messages
6,168,507
Members
452,194
Latest member
Lowie27

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