I have a column containing a spill range:
Cat
Dog
Cow
Pig
Chicken
The aim is to put these text values in another column but with 5 empty rows in between each value.
When new values are added into the spill range, the other column is updated continuing the 'every 5 rows' pattern. Likewise when values are removed.
The VBA code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range(Range("G2").SpillParent.Address)) Is Nothing Then
Columns(55).ClearContents
Dim srange As Range
Set srange = Range("G2").SpillingToRange
Range("BD2") = Range("G2").SpillingToRange.HasSpill
Range("BD4") = Range("G2").SpillingToRange.Address
Range("BD6") = Range("G2").SpillingToRange.count
Dim count As Long, i As Long, nextrow As Long
count = Range("G2").SpillingToRange.count + 1
nextrow = 2
For i = 2 To count
Sheet1.Cells(nextrow, 55).Value = Sheet1.Cells(i, 7).Value
nextrow = Cells(nextrow, 55).Offset(6, 1).Row
Next
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
The code returns an Object required
error when I enter the spill formula again to update the worksheet. When I went to track down the problem in a new worksheet, the code works fine and the Object required
error does not appear. The spill range calculates its values based on another column.
Any help will be greatly appreciated.