robertrobert905
Board Regular
- Joined
- Jun 27, 2008
- Messages
- 139
Hi everyoneI'm getting the runtime error '9', script out of range errors
1.The line of the error is Accountlist(AccountlistCount) = TempText
2.GetLastRowWithData is a function that returns an int
3. temptext is a string in a cell, e.g. Account:Company1
So am I not allowed to assign text to a dynamic array?
1.The line of the error is Accountlist(AccountlistCount) = TempText
2.GetLastRowWithData is a function that returns an int
3. temptext is a string in a cell, e.g. Account:Company1
So am I not allowed to assign text to a dynamic array?
Code:
Sub RawFileFix()
Dim Accountlist() As String
Dim AccountlistCount As Integer
Dim TempText As String
AccountlistCount = 1
Sheets("Raw files").Select
For i = 1 To GetLastRowWithData
If InStr(1, Range("A" & CStr(i)).Value, "Account") > 0 Then 'cell says Account:...
TempText = Range("A" & CStr(i)).Value
Accountlist(AccountlistCount) = TempText
AccountlistCount = AccountlistCount + 1
End If
Next i
For j = 1 To UBound(Accountlist)
Range("B" & CStr(j)).Value = Accountlist(j)
Next j
End Sub