Fill Uneven Records Across Columns

Frenzyy

New Member
Joined
May 26, 2019
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hi All,
Could you please help me find a way to fill in the blank cells that should start from the LastRow + 1 in Col B and go until LastRow in Col C?
At the moment the data is just being pasted over the lastrow in Col B. Loop in question is the last one, rest is just used to show more or less how the macro is working at the moment.

VBA Code:
For Each cell In rg2.Cells
            If IsDate(cell.Value) And cell.Value < processEnd Then
                NextRow = NextRow + 1
                cell.Resize(1, 1).Copy
                .Cells(NextRow, "C").PasteSpecial xlPasteValues
                .Cells(NextRow, "D").Value = cell.Offset(0, 1).Value
                .Cells(NextRow, "E").Value = cell.Offset(0, 1).Value
                .Cells(NextRow, "H").Value = cell.Offset(0, 3).Value
                .Cells(NextRow, "I").Value = cell.Offset(0, 5).Value
                .Cells(NextRow, "A").Value = "XXXX"
                .Cells(NextRow, "F").Formula = "=IF(LEFT(R[0]C[-2],5)=""TEST"",""TEST1"",""TEST2"")"
                .Cells(NextRow, "G").Formula = "=IF(LEFT(R[0]C[-2],5)=""TEST"",""TEST1"",""TEST2"")"
                .Cells(NextRow, "B").Formula = "=A2&C2&I2&ROW(I2)&RAND()"
                .Cells(NextRow, "J").Formula = "=IF(RC[-4]=""TESTX"",-RC[-1],RC[-1])"
            End If
        Next cell
        End With
        
        Range("C1").Select
        Selection.End(xlDown).Select
        Selection.End(xlDown).Select
        Range(Selection, Selection.End(xlDown)).Copy
        ActiveCell.Offset(1, 0).Range("A1").Select
        Selection.End(xlDown).Select
        ActiveCell.Offset(1, 0).Range("A1").Select
        ActiveSheet.Paste
        Selection.RemoveDuplicates Columns:=1
        Range("C1").Select
        
        With Worksheets(sh)
        lastrow2 = .Cells(.Rows.Count, "C").End(xlUp).row
        Set del = Range("C2:C" & lastrow2)
        For Each cell In del.Cells
        If cell.Value <> vbNullString Then
                .Cells(NextRow, "A").Value = "XXXX"
                .Cells(NextRow, "B").Value = "=A2&C2&I2&ROW(I2)&RAND()"
                .Cells(NextRow, "D").Value = "YYY"
                .Cells(NextRow, "E").Value = "NNN"
                .Cells(NextRow, "F").Formula = "=IF(RC[1]=""XYZ"",""X123"",""X321"")"
                .Cells(NextRow, "G").Formula = "=IF(RC[3]>0,""X321"", ""X123"")"
                .Cells(NextRow, "H").Formula = "=RC[1]"
                .Cells(NextRow, "I").Formula = "=ABS(RC[1])"
                .Cells(NextRow, "J").FormulaR1C1 = "=SUMIFS(C10,C3,RC3,C7,""Testing*"")"
                End If
                Next cell
        End With

Please let me know if you have any questions.
Many thanks!
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Frenzyy

New Member
Joined
May 26, 2019
Messages
22
Office Version
  1. 365
Platform
  1. Windows
If .Cells(cell.Row, "A").Value = vbNullString Then .Cells(cell.Row, "A").Value = "XXXX" is the solution.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,650
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Please take a minute to read the forum rules, especially about cross-posting, and follow them in future. Thanks. :)
 

Watch MrExcel Video

Forum statistics

Threads
1,114,002
Messages
5,545,440
Members
410,684
Latest member
LakTik
Top