Hi,
Please can somebody help me with the below code:
Sub Copy_Paste()
Dim DestSht As Worksheet
Dim SourceSht As Worksheet
Set DestSht = ThisWorkbook.Worksheets("Output Template")
Set SourceSht = ThisWorkbook.Worksheets("Input Template")
lastRow = SourceSht.Cells(Rows.Count, "A").End(xlUp).Row
SourceSht.Range("A5:DJ" & lastRow).Copy
DestSht.Range("A2:DJ" & lastRow).PasteSpecial xlPasteValues
End Sub
I am trying to copy rows starting from Row A5 to DJ in a sheet (Input Template) to the last row with data (the data range is not static) to a different sheet (Output Template) in the same workbook. The above code is working fine with copying and pasting the rows in the destination sheet (Output Template), however, the code is also copying the range which are blanks cells containing formulas (""). which is till Row 600.
Please can you suggest the code to copy till the last row having genuine data and avoid copying the cells which are blank with formulas.
Thanks.
Please can somebody help me with the below code:
Sub Copy_Paste()
Dim DestSht As Worksheet
Dim SourceSht As Worksheet
Set DestSht = ThisWorkbook.Worksheets("Output Template")
Set SourceSht = ThisWorkbook.Worksheets("Input Template")
lastRow = SourceSht.Cells(Rows.Count, "A").End(xlUp).Row
SourceSht.Range("A5:DJ" & lastRow).Copy
DestSht.Range("A2:DJ" & lastRow).PasteSpecial xlPasteValues
End Sub
I am trying to copy rows starting from Row A5 to DJ in a sheet (Input Template) to the last row with data (the data range is not static) to a different sheet (Output Template) in the same workbook. The above code is working fine with copying and pasting the rows in the destination sheet (Output Template), however, the code is also copying the range which are blanks cells containing formulas (""). which is till Row 600.
Please can you suggest the code to copy till the last row having genuine data and avoid copying the cells which are blank with formulas.
Thanks.