Assigning subsets of an array to a ranges within Excel

DonEB

Board Regular
Joined
Apr 26, 2016
Messages
128
Office Version
  1. 2019
Platform
  1. Windows
If this has been asked and answered, I apologize. I've attempted to search for the answer to this question and was unable to locate a solution.

I have an array called arrGoodCombo. It will be only a single row containing 17 values. The first (1, 2, 3 4) , second (5, 6. 7, 8), third (9, 10, 11, 12) and fourth (13, 14, 15, 15) set of values will contain unique player numbers ranging from 1 - 20. The 17th position will hold a cumulative total value which is used to help determine best selection of test to post to a schedule.

My dilemma has been figuring out how to place each of the different sets of values in arrGoodCombo into a specific range within excel. While I know this is not the appropriate way to do it, this is effectively what I'm trying to accomplish.

Worksheets("Quarterly Schedule").Range("C8:F8").Value = arrGoodCombo(1, 2, 3, 4)
Worksheets("Quarterly Schedule").Range("H8:K8").Value = arrGoodCombo(5, 6, 7, 8)
Worksheets("Quarterly Schedule").Range("M8:P8").Value = arrGoodCombo(9, 10, 11, 12)
Worksheets("Quarterly Schedule").Range("R8:U8").Value = arrGoodCombo(13, 14, 15, 16)

Might there be an easy solution? Thanks for any help or guidance you can provide.
Don
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
OK... I figured out how to write individual array values to individuals excel cells (example below) but still feel there has to be a better, more efficient way of doing this. I'm still researching but if anyone has any thoughts, it would be much appreciated.
Worksheets("Quarterly Schedule").Range("C8").Value = arrGoodCombo(1, 1)
Worksheets("Quarterly Schedule").Range("D8").Value = arrGoodCombo(2, 1)
Worksheets("Quarterly Schedule").Range("E8").Value = arrGoodCombo(3, 1)
Worksheets("Quarterly Schedule").Range("F8").Value = arrGoodCombo(4, 1)
Worksheets("Quarterly Schedule").Range("H8").Value = arrGoodCombo(5, 1), etc.

As an FYI, arrGoodCombo was originally defined as follows: Public arrGoodCombo() As Variant
It was subsequently redefined as follows: ReDim arrGoodCombo(16). Note: it is redefined based on the number of player numbers that are being worked with.
 
Upvote 0

Forum statistics

Threads
1,215,089
Messages
6,123,058
Members
449,091
Latest member
ikke

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