Jaymond Flurrie
Well-known Member
- Joined
- Sep 22, 2008
- Messages
- 919
- Office Version
- 365
- Platform
- Windows
How do I make the following code to work? I need an array that has nothing but strings in it and has two dimensions (X rows, 5 columns). The amount of rows changes a lot, it can be one, it can be one thousand.
It gives now "Run-time error '9': Subscript out of range error"
The problem is most likely on that "Dim sHaettavat() As String" row, but how do I fix it? "Dim sHaettavat(,5) As String" doesn't work either.
Am I forced to use some kind of variant even if there's nothing but strings?
Code:
Sub arraytest()
Dim sHaettavat() As String
Dim lRow As Long
lRow = 1 'This can be any positive integer
sHaettavat(lRow, 1) = "0.0.1.0."
sHaettavat(lRow, 2) = "002F_002A_"
sHaettavat(lRow, 3) = "002F_"
sHaettavat(lRow, 4) = "No"
sHaettavat(lRow, 5) = "Comment"
End Sub
The problem is most likely on that "Dim sHaettavat() As String" row, but how do I fix it? "Dim sHaettavat(,5) As String" doesn't work either.
Am I forced to use some kind of variant even if there's nothing but strings?