Fill Uneven Records Across Columns

Frenzyy

New Member
Joined
May 26, 2019
Messages
24
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!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
If .Cells(cell.Row, "A").Value = vbNullString Then .Cells(cell.Row, "A").Value = "XXXX" is the solution.
 
Upvote 0
Please take a minute to read the forum rules, especially about cross-posting, and follow them in future. Thanks. :)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,193
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top