VBA short cuts?

Russk68

Well-known Member
Joined
May 1, 2006
Messages
589
Office Version
  1. 365
Platform
  1. MacOS
Hi all!
I have to put these ranges in for 40 layouts (Distros). I was wondering if there was an easier way to write this.
Something like this for example: C5:M49, except every other column and repeat every 4th row. Or do I just need to input each cell like I'm doing?
Also,
Is it possible to to replace text like with "Find and Replace"? Like if I highlighted C5,E5,G5,I5,K5,M5 I would like to replace 5 with 9.

(FYI, I am on a MAC and I can't put in all 96 ranges on 1 line and that's why I am using 2 line per layout

VBA Code:
'Distro 1
    Set rng = Range("C5,E5,G5,I5,K5,M5,C9,E9,G9,I9,K9,M9,C13,E13,G13,I13,K13,M13,C17,E17,G17,I17,K17,M17,C21,E21,G21,I21,K21,M21,C25,E25,G25,I25,K25,M25")
   Set rng = Union(rng, Range("C29,E29,G29,I29,K29,M29,C33,E33,G33,I33,K33,M33,C37,E37,G37,I37,K37,M37,C41,E41,G41,I41,K41,M41,C45,E45,G45,I45,K45,M45,C49,E49,G49,I49,K49,M49"))
'Distro 2
   Set rng = Union(rng, Range("C58,E58,G58,I58,K58,M58,C62,E62,G62,I62,K62,M62,C66,E66,G66,I66,K66,M66,C70,E70,G70,I70,K70,M70,C74,E74,G74,I74,K74,M74,C78,E78,G78,I78,K78,M78"))
   Set rng = Union(rng, Range("C82,E82,G82,I82,K82,M82,C86,E86,G86,I86,K86,M86,C90,E90,G90,I90,K90,M90,C94,E94,G94,I94,K94,M94,C98,E98,G98,I98,K98,M98,C102,E102,G102,I102,K102,M102"))
   
        If Len(Target.Value) = 0 Then
           Application.EnableEvents = False
                Target.Value = "Spare"
            Application.EnableEvents = True
         End If

/CODE]

TIA!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Do the cells in between the ones you are writing into have data in them or formula??? If it is only data you could load the whole area into a variant array, loop through the columns and rows to make the changes and then write the whole array back. This doesn't work if you have formulae because it overwrites the formula
 
Upvote 0

Forum statistics

Threads
1,223,707
Messages
6,174,000
Members
452,542
Latest member
Bricklin

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