Fill Uneven Records Across Columns

Frenzyy

New Member
Joined
May 26, 2019
Messages
22
Office Version
365
Platform
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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Frenzyy

New Member
Joined
May 26, 2019
Messages
22
Office Version
365
Platform
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,177
Office Version
365, 2019, 2016, 2010
Platform
Windows, 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,102,907
Messages
5,489,654
Members
407,703
Latest member
Chibuzo

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top