I am learning visual basic and this script I'm using is coming up with an error when I am initializing the variable i.
I'm not sure what the problem is but I am getting the error message:
Run-time error '1004': Application-defined or object-defined error
Here is my code:
Sub excelmacro()
Sheets("Sheet1").Select
Range("A1").Select
Sheets("Sheet2").Select
Range("B1").Select
i = 1
While i <> 10
    If Len(ActiveCell.Value) > 1 Then
        Sheets("Sheet1").Select
        xname = Right(ActiveCell.Value, Len(ActiveCell.Value) - 6)
        xsalary = Right(ActiveCell.Value, Len(ActiveCell.Offset(2, 0).Value) - 8)
        xdesignation = Right(ActiveCell.Value, Len(ActiveCell.Offset(1, 0).Value) - 13)
        Sheets("Sheet2").Select
        ActiveCell.Value = xname
        ActiveCell.Offset(0, 1).Value = xdesig
        ActiveCell.Offset(0, 3).Value = xsalary
        ActiveCell.Offset(1, 0).Select
        Sheets("Sheet1").Select
        ActiveCell.Offset(3, 0).Select
    Else
        i = 10
    End If
Wend
End Sub
 
     
    