Sub nationalityscript()
Dim i As Integer
Dim temp As Integer
Dim Country As String
Dim strEnd As Integer
Dim strComplete As String
i = 0
Do While i < 300
Dim k As Integer
Dim a As String
strComplete = Cells(h, i).Value
strEnd = Len(strComplete)
k = 0
Do While k < strEnd
a = Cells(h, i).Value.Substring(k, k)
If a = "," Then
temp = a
End If
k = k + 1
Loop
Country = Cells(h, i).Value.Substring(temp, strEnd)
i = i + 1
Loop
End Sub
Hi, This is my first day programming in vba so please go easy on me.
I am writing a macro in excel to focusing on column h. any string found in column h the code will go through, Identify the last part of the string after the last "," and then replace the string in that cell with the sub-string it got.
I think this might be irrelevant to my question though because my problem is assigning the string in the cell to a new variable.
My issue is with the line highlighted here.

The error I am getting is:
Runtime-Error 1004, object-defined or application-defined error.