(Solved) – excel vba array for portion of range and formula?

(solved)-–-excel-vba-array-for-portion-of-range-and-formula?

I’m not exactly sure how or if I need to do multiple arrays to get to my end goal.

I have to do this for range column D, E, F, G, H, and I and for formula portion of Morning, Mid, Evening, and Weekend on the sames sheet. Morning range is 1-75, Mid is range 76-150, Evening range is 151-225, and Weekend range is 226-300. What I’m trying to do is condense my code and clean it up.

Here’s an example of what I mean for D column on Weekend formula portion.

Worksheets("InsightsData").Range("D226").Formula = "=Weekend!$B$82"
Worksheets("InsightsData").Range("D227").Formula = "=Weekend!$B$144"
Worksheets("InsightsData").Range("D228").Formula = "=Weekend!$B$206"
Worksheets("InsightsData").Range("D229").Formula = "=Weekend!$B$268"
Worksheets("InsightsData").Range("D230").Formula = "=Weekend!$B$330"
Worksheets("InsightsData").Range("D231").Formula = "=Weekend!$B$392"
Worksheets("InsightsData").Range("D232").Formula = "=Weekend!$B$454"
Worksheets("InsightsData").Range("D233").Formula = "=Weekend!$B$516"
Worksheets("InsightsData").Range("D234").Formula = "=Weekend!$B$578"
Worksheets("InsightsData").Range("D235").Formula = "=Weekend!$B$640"
Worksheets("InsightsData").Range("D236").Formula = "=Weekend!$B$702"
Worksheets("InsightsData").Range("D237").Formula = "=Weekend!$B$764"
Worksheets("InsightsData").Range("D238").Formula = "=Weekend!$B$826"
Worksheets("InsightsData").Range("D239").Formula = "=Weekend!$B$888"
Worksheets("InsightsData").Range("D240").Formula = "=Weekend!$B$950"
Worksheets("InsightsData").Range("D241").Formula = "=Weekend!$B$1012"
Worksheets("InsightsData").Range("D242").Formula = "=Weekend!$B$1074"
Worksheets("InsightsData").Range("D243").Formula = "=Weekend!$B$1136"
Worksheets("InsightsData").Range("D244").Formula = "=Weekend!$B$1198"
Worksheets("InsightsData").Range("D245").Formula = "=Weekend!$B$1260"
Worksheets("InsightsData").Range("D246").Formula = "=Weekend!$B$1322"
Worksheets("InsightsData").Range("D247").Formula = "=Weekend!$B$1384"
Worksheets("InsightsData").Range("D248").Formula = "=Weekend!$B$1446"
Worksheets("InsightsData").Range("D249").Formula = "=Weekend!$B$1508"
Worksheets("InsightsData").Range("D250").Formula = "=Weekend!$B$1570"
Worksheets("InsightsData").Range("D251").Formula = "=Weekend!$B$1632"
Worksheets("InsightsData").Range("D252").Formula = "=Weekend!$B$1694"
Worksheets("InsightsData").Range("D253").Formula = "=Weekend!$B$1756"
Worksheets("InsightsData").Range("D254").Formula = "=Weekend!$B$1818"
Worksheets("InsightsData").Range("D255").Formula = "=Weekend!$B$1880"
Worksheets("InsightsData").Range("D256").Formula = "=Weekend!$B$1942"
Worksheets("InsightsData").Range("D257").Formula = "=Weekend!$B$2004"
Worksheets("InsightsData").Range("D258").Formula = "=Weekend!$B$2066"
Worksheets("InsightsData").Range("D259").Formula = "=Weekend!$B$2128"
Worksheets("InsightsData").Range("D260").Formula = "=Weekend!$B$2190"
Worksheets("InsightsData").Range("D261").Formula = "=Weekend!$B$2252"
Worksheets("InsightsData").Range("D262").Formula = "=Weekend!$B$2314"
Worksheets("InsightsData").Range("D263").Formula = "=Weekend!$B$2376"
Worksheets("InsightsData").Range("D264").Formula = "=Weekend!$B$2438"
Worksheets("InsightsData").Range("D265").Formula = "=Weekend!$B$2500"
Worksheets("InsightsData").Range("D266").Formula = "=Weekend!$B$2562"
Worksheets("InsightsData").Range("D267").Formula = "=Weekend!$B$2624"
Worksheets("InsightsData").Range("D268").Formula = "=Weekend!$B$2686"
Worksheets("InsightsData").Range("D269").Formula = "=Weekend!$B$2748"
Worksheets("InsightsData").Range("D270").Formula = "=Weekend!$B$2810"
Worksheets("InsightsData").Range("D271").Formula = "=Weekend!$B$2872"
Worksheets("InsightsData").Range("D272").Formula = "=Weekend!$B$2934"
Worksheets("InsightsData").Range("D273").Formula = "=Weekend!$B$2996"
Worksheets("InsightsData").Range("D274").Formula = "=Weekend!$B$3058"
Worksheets("InsightsData").Range("D275").Formula = "=Weekend!$B$3120"
Worksheets("InsightsData").Range("D276").Formula = "=Weekend!$B$3182"
Worksheets("InsightsData").Range("D277").Formula = "=Weekend!$B$3244"
Worksheets("InsightsData").Range("D278").Formula = "=Weekend!$B$3306"
Worksheets("InsightsData").Range("D279").Formula = "=Weekend!$B$3368"
Worksheets("InsightsData").Range("D280").Formula = "=Weekend!$B$3430"
Worksheets("InsightsData").Range("D281").Formula = "=Weekend!$B$3492"
Worksheets("InsightsData").Range("D282").Formula = "=Weekend!$B$3554"
Worksheets("InsightsData").Range("D283").Formula = "=Weekend!$B$3616"
Worksheets("InsightsData").Range("D284").Formula = "=Weekend!$B$3678"
Worksheets("InsightsData").Range("D285").Formula = "=Weekend!$B$3740"
Worksheets("InsightsData").Range("D286").Formula = "=Weekend!$B$3802"
Worksheets("InsightsData").Range("D287").Formula = "=Weekend!$B$3864"
Worksheets("InsightsData").Range("D288").Formula = "=Weekend!$B$3926"
Worksheets("InsightsData").Range("D289").Formula = "=Weekend!$B$3988"
Worksheets("InsightsData").Range("D290").Formula = "=Weekend!$B$4050"
Worksheets("InsightsData").Range("D291").Formula = "=Weekend!$B$4112"
Worksheets("InsightsData").Range("D292").Formula = "=Weekend!$B$4174"
Worksheets("InsightsData").Range("D293").Formula = "=Weekend!$B$4236"
Worksheets("InsightsData").Range("D294").Formula = "=Weekend!$B$4298"
Worksheets("InsightsData").Range("D295").Formula = "=Weekend!$B$4360"
Worksheets("InsightsData").Range("D296").Formula = "=Weekend!$B$4422"
Worksheets("InsightsData").Range("D297").Formula = "=Weekend!$B$4484"
Worksheets("InsightsData").Range("D298").Formula = "=Weekend!$B$4546"
Worksheets("InsightsData").Range("D299").Formula = "=Weekend!$B$4608"
Worksheets("InsightsData").Range("D300").Formula = "=Weekend!$B$4670"

The way I have it done now yields around 1800 lines of code. There has to be a simpler way to do this.

Leave a Reply

Your email address will not be published. Required fields are marked *