Is there away to shorten

S

Steved

Hello from Steved

Is their away please to shorten the below part off the code thankyou.

("K1:L1,N1:O1,Q1:R1,T1:U1,W1:X1,Z1:AA1,AC1:AD1,AF1:AG1,AI1:AJ1,AL1:AM1,AO1:AP1")

Private Sub CheckBox1_Click()
Dim r As Range
Set r =
Range("K1:L1,N1:O1,Q1:R1,T1:U1,W1:X1,Z1:AA1,AC1:AD1,AF1:AG1,AI1:AJ1,AL1:AM1,AO1:AP1")
r.EntireColumn.Hidden = Not r.EntireColumn.Hidden
End Sub
 
G

Gary''s Student

This builds the same range. It will take a tiny bit longer to execute, but
who wants to type in all those cell pairs??

Sub SteveD()
Set r = Range("K1:L1")
For i = 14 To 41 Step 3
Set r = Union(r, Range(Cells(1, i), Cells(1, i + 1)))
Next
End Sub
 
S

Steved

Thankyou.

Gary''s Student said:
This builds the same range. It will take a tiny bit longer to execute, but
who wants to type in all those cell pairs??

Sub SteveD()
Set r = Range("K1:L1")
For i = 14 To 41 Step 3
Set r = Union(r, Range(Cells(1, i), Cells(1, i + 1)))
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top