Hi. i'm having trouble in running VBA code. Actually, i have to split values from Column F delimited by "-" to adjacent cell which is shown in excel file. For that i have written the below code. The codes works fine splitting values in Column F but throws a "Run Time error'1004". Is there any solution to stop this bug. I wonder why it is happening. Plz Suggest me.
Code:
Dim myRng As Object
Dim rwCount As Long
Dim i As Long
Dim vA As Variant
rwCount = Application.WorksheetFunction.CountA(Sheets("PAY SCALES 1").Range("F1:F" & Rows.Count))
Set myRng = Worksheets("PAY SCALES 1").Range("F1:F" & rwCount)
ActiveWorkbook.Worksheets("PAY SCALES 1").Select
Range("G1:BC" & Rows.Count).Clear ' to clear unncessary content in cells
With myRng.Select
For i = 2 To rwCount
vA = Split(myRng.Resize(1).Offset(i - 1), "-")
myRng.Offset(i - 1).Resize(1, UBound(vA) + 1).Offset(, 1) = vA
Next
End With
Range("G1").Select