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.
Please let me know if you have any questions.
Many thanks!
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!