Hello,
I'm using the split function to isolate the second portion of a string. Depending on what that second portion is, a particular heading is added to a worksheet. However, occasionally this second portion might be blank. This returns the following error:
"Run time error (9): Subscript out of range"
My code is something like this:
Can anyone advise me as to handle a potentially blank value for k?
Thanks!
I'm using the split function to isolate the second portion of a string. Depending on what that second portion is, a particular heading is added to a worksheet. However, occasionally this second portion might be blank. This returns the following error:
"Run time error (9): Subscript out of range"
My code is something like this:
Code:
Dim k as variant
Dim POnumber as string
POnumber="12345-Germany"
k=Split(POnumber, "-")
If k(2)="Germany" then 'if k is nothing, the code returns an error here
Cells(10,3).value = "GermanyHeader"
Elseif k(2)="France" then
Cells(10,3).value= "FranceHeader"
end if
Thanks!