Hi
Please can you help.
I am new to programming and maybe mixing up different languages.
The goal of my code is to collect the names of all the columns currently in my excel sheet.
The excel sheet can change in width (more or less columns) and content (heading names)
I am hoping get an array with all column headings in it
Heading (A1, B1, C1)
Then use heading(0) to call A1 into my code.
Is it possible to do this?
If so, any idea where I am going wrong?
Thanks
Phil
Please can you help.
I am new to programming and maybe mixing up different languages.
The goal of my code is to collect the names of all the columns currently in my excel sheet.
The excel sheet can change in width (more or less columns) and content (heading names)
Code:
Dim i As Integer
i = 0
Range("A1").Activate ' row 1 contains column headings
Do While Not IsEmpty(ActiveCell) ' stop if the column heading is empty
Heading(i) = ActiveCell.Value ' copy the heading name into array positon 0
ActiveCell.Offset(, 1).Activate ' move across to the next heading.
i = i + 1 ' increase array position by 1
Loop ' loop until the end of the headings
I am hoping get an array with all column headings in it
Heading (A1, B1, C1)
Then use heading(0) to call A1 into my code.
Is it possible to do this?
If so, any idea where I am going wrong?
Thanks
Phil
Last edited: