How do I shorten up this code sequence

berenger

Board Regular
Joined
Jun 6, 2011
Messages
50
I am new to vba code writing and the code I have is working for me but I would like to know if there is a way to shorten it up but continue to function the same way.

Code:
If Sheets("Scan Here").Range("O2") = True Then Range("B2").Value = Sheets("Labels1").Range("L1")
If Sheets("Scan Here").Range("O3") = True Then Range("E2").Value = Sheets("Labels1").Range("M1")
If Sheets("Scan Here").Range("O4") = True Then Range("H2").Value = Sheets("Labels1").Range("N1")
If Sheets("Scan Here").Range("O5") = True Then Range("K2").Value = Sheets("Labels1").Range("O1")
If Sheets("Scan Here").Range("O6") = True Then Range("B6").Value = Sheets("Labels1").Range("L2")
If Sheets("Scan Here").Range("O7") = True Then Range("E6").Value = Sheets("Labels1").Range("M2")
If Sheets("Scan Here").Range("O8") = True Then Range("H6").Value = Sheets("Labels1").Range("N2")
If Sheets("Scan Here").Range("O9") = True Then Range("K6").Value = Sheets("Labels1").Range("O2")
If Sheets("Scan Here").Range("O10") = True Then Range("B10").Value = Sheets("Labels1").Range("L3")
If Sheets("Scan Here").Range("O11") = True Then Range("E10").Value = Sheets("Labels1").Range("M3")
If Sheets("Scan Here").Range("O12") = True Then Range("H10").Value = Sheets("Labels1").Range("N3")
If Sheets("Scan Here").Range("O13") = True Then Range("K10").Value = Sheets("Labels1").Range("O3")
If Sheets("Scan Here").Range("O14") = True Then Range("B14").Value = Sheets("Labels1").Range("L4")
If Sheets("Scan Here").Range("O15") = True Then Range("E14").Value = Sheets("Labels1").Range("M4")
If Sheets("Scan Here").Range("O16") = True Then Range("H14").Value = Sheets("Labels1").Range("N4")
If Sheets("Scan Here").Range("O17") = True Then Range("K14").Value = Sheets("Labels1").Range("O4")
If Sheets("Scan Here").Range("O18") = True Then Range("B18").Value = Sheets("Labels1").Range("L5")
If Sheets("Scan Here").Range("O19") = True Then Range("E18").Value = Sheets("Labels1").Range("M5")
If Sheets("Scan Here").Range("O20") = True Then Range("H18").Value = Sheets("Labels1").Range("N5")
If Sheets("Scan Here").Range("O21") = True Then Range("K18").Value = Sheets("Labels1").Range("O5")
If Sheets("Scan Here").Range("O22") = True Then Range("B22").Value = Sheets("Labels1").Range("L6")
If Sheets("Scan Here").Range("O23") = True Then Range("E22").Value = Sheets("Labels1").Range("M6")
If Sheets("Scan Here").Range("O24") = True Then Range("H22").Value = Sheets("Labels1").Range("N6")
If Sheets("Scan Here").Range("O25") = True Then Range("K22").Value = Sheets("Labels1").Range("O6")
If Sheets("Scan Here").Range("O26") = True Then Range("B26").Value = Sheets("Labels1").Range("L7")
If Sheets("Scan Here").Range("O27") = True Then Range("E26").Value = Sheets("Labels1").Range("M7")
If Sheets("Scan Here").Range("O28") = True Then Range("H26").Value = Sheets("Labels1").Range("N7")
If Sheets("Scan Here").Range("O29") = True Then Range("K26").Value = Sheets("Labels1").Range("O7")
If Sheets("Scan Here").Range("O30") = True Then Range("B30").Value = Sheets("Labels1").Range("L8")
If Sheets("Scan Here").Range("O31") = True Then Range("E30").Value = Sheets("Labels1").Range("M8")
If Sheets("Scan Here").Range("O32") = True Then Range("H30").Value = Sheets("Labels1").Range("N8")
If Sheets("Scan Here").Range("O33") = True Then Range("K30").Value = Sheets("Labels1").Range("O8")
 
Berenger

The original code doesn't seem to refer to any option buttons.

Are there only 2 or do you actually have a whole bunch of them?
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Norie you are correct I didn't list them in my original code. But my userform only has the 2 radio buttons on them. If you want I can list my entire code of this userform.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

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