hi...
i using the following code to split cells in Column A depending upon number of cells containing text or numbers separated by delimiter "-". It works fine. But when i tried this code in a worksheet after changing the value, it gets runtime error '1004' - Application defined or object defined error. I need Why it is not working. The code is attached to sheet1 and it should execute when a value changes in any of the cell in Column A.
Thanks in Advance for Valuable Suggestion.
i using the following code to split cells in Column A depending upon number of cells containing text or numbers separated by delimiter "-". It works fine. But when i tried this code in a worksheet after changing the value, it gets runtime error '1004' - Application defined or object defined error. I need Why it is not working. The code is attached to sheet1 and it should execute when a value changes in any of the cell in Column A.
Thanks in Advance for Valuable Suggestion.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rwCount As Long
Dim i As Long
Dim vA As Variant
rwCount = Application.WorksheetFunction.CountA(Sheet1.Range("A1:A" & Rows.Count))
For i = 1 To rwCount
vA = Split(Selection.Resize(1).Offset(i - 1), "-")
Selection.Offset(i - 1).Resize(1, UBound(vA) + 1).Offset(, 1) = vA
Next
End Sub