I am building a P&L on worksheet(1) based on data from worksheet(2). I need to copy rows of data from worksheet(2) and paste onto worksheet(1). The pasting process needs to find a named range (one cell) on worksheet(1) and insert a row for the copied data above the named cell. In addition, each row on worksheet(2) must first be identified by a cell value in row (d) and be pasted to a corresponding named cell.
Source = Worksheet(2)
Destination Worksheet(1)
Worksheet(2) and has hundreds of rows
Worksheet(2) column (d) has the identifier value(s), like 1000 and 1100, which both need to go to the gross sales section on worksheet(1) –the code below only has 1000.
Worksheet(1) has a named range called RPT_GS. The copied data needs to be inserted above the named range RPT_GS.
The code below is a mess and does not find the named range RPT_GS. If the below code is so ugly, please feel free to start over. I really appreciate any help. Thanks, John
Sub FIND_COPY_PASTE _1000()
Dim DestSheet As Worksheet
Set DestSheet = Worksheets("she et 1")
Dim sRow As Long
Dim dRow As Long
Dim sCount As Long
sCount = 0
dRow = 1
For sRow = 1 To Range("D360").E nd(xlUp).Row
If Cells(sRow, "D") Like "1000" Then
sCount = sCount + 0
dRow = dRow + 1
'Cells(sRow, "F").Copy Destination:=De stSheet.Cells(d Row, "B")
'Cells(sRow, "E").Copy Destination:=De stSheet.Cells(d Row, "C")
'Cells(sRow, "D").Copy Destination:=De stSheet.Cells(d Row, "D")
End If
Next sRow
Source = Worksheet(2)
Destination Worksheet(1)
Worksheet(2) and has hundreds of rows
Worksheet(2) column (d) has the identifier value(s), like 1000 and 1100, which both need to go to the gross sales section on worksheet(1) –the code below only has 1000.
Worksheet(1) has a named range called RPT_GS. The copied data needs to be inserted above the named range RPT_GS.
The code below is a mess and does not find the named range RPT_GS. If the below code is so ugly, please feel free to start over. I really appreciate any help. Thanks, John
Sub FIND_COPY_PASTE _1000()
Dim DestSheet As Worksheet
Set DestSheet = Worksheets("she et 1")
Dim sRow As Long
Dim dRow As Long
Dim sCount As Long
sCount = 0
dRow = 1
For sRow = 1 To Range("D360").E nd(xlUp).Row
If Cells(sRow, "D") Like "1000" Then
sCount = sCount + 0
dRow = dRow + 1
'Cells(sRow, "F").Copy Destination:=De stSheet.Cells(d Row, "B")
'Cells(sRow, "E").Copy Destination:=De stSheet.Cells(d Row, "C")
'Cells(sRow, "D").Copy Destination:=De stSheet.Cells(d Row, "D")
End If
Next sRow
Comment