Hey Everyone,
There is an issue im running into here and I cant figure it out.
I have a program to take account numbers and separate them into single rows, once they populate into the new rows I want to get the blanks to fill with the information from the account in the rows adjacent to them. If I use the last row method the macro returns ref, but if I use a set number of rows this does not occur.
Here is my current code.
Sub TMPfriendly()
Dim rindex As Long
Dim saItem() As String
Dim rng As Range
Dim LastRow As Long
Dim ws As Worksheet
Set ws = ActiveSheet
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For rindex = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If InStr(Cells(rindex, "A").Value, "/") > 0 Then
saItem = Split(Cells(rindex, "A").Value, "/")
Rows(rindex + 1 & ":" & rindex + UBound(saItem)).Insert
Cells(rindex, "A").Resize(UBound(saItem) + 1).Value = WorksheetFunction.Transpose(saItem)
End If
Next rindex
On Error Resume Next
With Range("A2" & LastRow)
On Error Resume Next
Set myRange = .SpecialCells(xlCellTypeBlanks) 'check for blank cells
On Error GoTo 0
If Not myRange Is Nothing Then 'if there are blanks then...
myRange.FormulaR1C1 = "=R[-1]C" 'Formula to return data in cell above
.Value = .Value 'fix formula vales to fixed constant values
Else
End If
End With
Columns("B:B").Select
ActiveSheet.Range("$A$1:$R" & LastRow).RemoveDuplicates Columns:=2, Header:=xlYes
End Sub
So it breaks column A into individual rows, and then scans for blanks, it should take the information from the cell above, and then copy that into the cell below for columns b-f (G-R) do not need to fill blanks at all they can be left as is.
The problem is the worksheet can change length so I tried to add the last row, now I get REF! instead of the name from the cell above on any instance where there are multiple splits
Bookmarks