tjdickinson
Board Regular
- Joined
- Jun 26, 2021
- Messages
- 61
- Office Version
- 365
- Platform
- Windows
In one sheet, I have essentially five tables stacked vertically with a spacer row between each table. (Table here meaning just a set of data, not an Excel Table.) I'm trying to fill the first and last columns of each table with the same array of times. In my code, I have declared the following variables:
Then I declare the array:
And finally I fill the ranges with the array:
What I get, however, is the array correctly filled in A2:A15, A36:A49, A70:A83 (and the same for column U). It skips over A19:A32 and A53:A66.
Originally, I had one range containing A2:A15, U2:U15, A19:A32, U19:U32, etc. After running the macro, only column A was filled in, not column U. I thought it was having trouble filling two different columns, so I separated the ranges. But with the current results, I realise that it was simply skipping every other range area (thus, all the U ranges).
Can anyone explain to me why this is happening and how I can fix it?
Thanks in advance for your help!
VBA Code:
Dim timeColA As Range: Set timeColA = Range("A2:A15, A19:A32, A36:A49, A53:A66, A70:A83")
Dim timeColU As Range: Set timeColU = Range("U2:U15, U19:U32, U36:U49, U53:U66, U70:U83")
VBA Code:
Dim timeFill As Variant: timeFill = VBA.Array("", "8:00", "8:20", "9:10", "10:00", "10:20", "11:10", "12:00", "12:30", "13:00", "13:50", "14:40", "15:00", "15:50")
timeFill = Application.WorksheetFunction.Transpose(timeFill)
VBA Code:
timeColA.Value = timeFill
timeColU.Value = timeFill
Originally, I had one range containing A2:A15, U2:U15, A19:A32, U19:U32, etc. After running the macro, only column A was filled in, not column U. I thought it was having trouble filling two different columns, so I separated the ranges. But with the current results, I realise that it was simply skipping every other range area (thus, all the U ranges).
Can anyone explain to me why this is happening and how I can fix it?
Thanks in advance for your help!