VBA: Output Headers from Array to Sheet Range

zero269

Active Member
Joined
Jan 16, 2023
Messages
335
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm trying to figure out the best approach to output the header values from my array to the worksheet. Currently I'm using this manual method:

VBA Code:
'Declarations
Dim FirstCol As String: FirstCol = arrSettings(LBound(arrSettings), 7)
Dim LastCol As String: LastCol = arrSettings(UBound(arrSettings), 7)

'Headers
With wsLogs.Range(FirstCol & "2:" & LastCol & "2") 'wsLogs CodeName
    .Font.Bold = True
    .Value = Array("Quiz", "Title", "Page", "Book", "Level", "Words", "Status", "List", "Media")
End With

1739067784563.png

However, all of these values are stored in my array in their #1 slot such as arrSettings(1,1)

1739067664025.png

I'm confident I could ultimately output one value and then offset by a column, but I would like to be able to reproduce the above if possible using the values stored in the arrSettings array.

Thank you. Any help would be greatly appreciated...
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Seems like an awkward way to store the information & I don't have all the array values to test, but try this

Rich (BB code):
.Value = Array("Quiz", "Title", "Page", "Book", "Level", "Words", "Status", "List", "Media")
.Value = Application.Transpose(Application.Index(arrSettings, 0, 1))
 
Upvote 1
Solution
Thanks Peter!

That did the trick! I knew there was a better way than me trying to loop and offset.

At first I wasn't sure how this was going to work, but now that I was able to see what you were doing as it relates to a Formula in the sheet... I tested it out there too, and can see what you did more clearly now. This was very helpful.

Now I can use this to work with the other data in the array by first testing it with the Table data.

1739074539170.png

The data in the array are settings for formatting reports/logs to ensure consistency. It's also my test bed for working with arrays... so far so good with your help and several others here. (y)
 
Upvote 0

Forum statistics

Threads
1,226,462
Messages
6,191,177
Members
453,644
Latest member
karlpravin

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