Squareroot
New Member
- Joined
- Nov 9, 2022
- Messages
- 15
- Office Version
- 2021
- Platform
- Windows
Hi,
I am trying to generate headers for a table. I decided to create a function just to generate header for my table. and to decide which row the header will go to my idea is to put the first element of my array(array that will be pass into the function)as the row number. following is my code.
Function create(header)
For x = 1 To 5
Sheets(1).Cells(header(0), x).Value = header(x)
Sheets(1).Cells(header(0), x).Interior.ColorIndex = 43
Next x
End Function
XXXXXXXXXXXXXXXXXXXXXXXXX main function XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Dim header As Variant
....
...
create (header = Array(1, "apple", "banana.", "carrot", "durian", "eggplant" ))
create (header = Array(2, "a", "b", "c", "d", "e" ))
the above code is not working as it will give me mismatch data type. Does anyone know how I can pass both int and string using the same array? or VBA doesn't allow user to do that.
I am trying to generate headers for a table. I decided to create a function just to generate header for my table. and to decide which row the header will go to my idea is to put the first element of my array(array that will be pass into the function)as the row number. following is my code.
Function create(header)
For x = 1 To 5
Sheets(1).Cells(header(0), x).Value = header(x)
Sheets(1).Cells(header(0), x).Interior.ColorIndex = 43
Next x
End Function
XXXXXXXXXXXXXXXXXXXXXXXXX main function XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Dim header As Variant
....
...
create (header = Array(1, "apple", "banana.", "carrot", "durian", "eggplant" ))
create (header = Array(2, "a", "b", "c", "d", "e" ))
the above code is not working as it will give me mismatch data type. Does anyone know how I can pass both int and string using the same array? or VBA doesn't allow user to do that.