Macro copy cell range sheet to sheet

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
471
Office Version
  1. 365
Platform
  1. Windows
Hi would anyone have a macro that would copy data from
Sheet 1 range C1 to F2000 to next available row on sheet 2 column C
but only if data is entered in the row of to column C
and
Sheet 3 range C1 to F2000 to next available row on sheet 4 column C
but only if data is entered in the row of to column C
So as shown in example, data would stop copying at row 20
Thanks

Book1
ABCDEFG
1a1b7
2a2b8
3a3b9
4a4b10
5a5b11
6a6b12
7a7b13
8a8b14
9a9b15
10a10b16
11a11b17
12a12b18
13a13b19
14a14b20
15a15b21
16a16b22
17a17b23
18a18b24
19a19b25
20b26
21b27
22b28
23b29
24b30
25b31
26b32
27b33
28b34
29b35
30b36
Sheet1
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try below,
VBA Code:
Sub Paste_NextRow()

    Dim wsCopySh1 As Worksheet
    Dim wsPasteSh2 As Worksheet
    Set wsCopySh1 = Sheets("Sheet1")
    Set wsPasteSh2 = Sheets("Sheet2")
    Dim lastRowSh2 As Long
    lastRowSh2 = ThisWorkbook.Sheets("Sheet2").Cells(Rows.Count, 3).End(xlUp).Row + 1
    Dim N As Long
    N = wsCopySh1.Range("c" & Rows.Count).End(xlUp).Row
    wsCopySh1.Range("c1:f" & N).Copy wsPasteSh2.Range("C" & lastRowSh2)
    
    '---------------------------------------
    
    Dim wsCopySh3 As Worksheet
    Dim wsPasteSh4 As Worksheet
    Set wsCopySh3 = Sheets("Sheet3")
    Set wsPasteSh4 = Sheets("Sheet4")
    Dim lastRowSh4 As Long
    lastRowSh4 = ThisWorkbook.Sheets("Sheet4").Cells(Rows.Count, 3).End(xlUp).Row + 1
    Dim M As Long
    M = wsCopySh3.Range("c" & Rows.Count).End(xlUp).Row
    wsCopySh3.Range("c1:f" & M).Copy wsPasteSh4.Range("C" & lastRowSh4)

End Sub
 
Upvote 0
Try below,
VBA Code:
Sub Paste_NextRow()

    Dim wsCopySh1 As Worksheet
    Dim wsPasteSh2 As Worksheet
    Set wsCopySh1 = Sheets("Sheet1")
    Set wsPasteSh2 = Sheets("Sheet2")
    Dim lastRowSh2 As Long
    lastRowSh2 = ThisWorkbook.Sheets("Sheet2").Cells(Rows.Count, 3).End(xlUp).Row + 1
    Dim N As Long
    N = wsCopySh1.Range("c" & Rows.Count).End(xlUp).Row
    wsCopySh1.Range("c1:f" & N).Copy wsPasteSh2.Range("C" & lastRowSh2)
   
    '---------------------------------------
   
    Dim wsCopySh3 As Worksheet
    Dim wsPasteSh4 As Worksheet
    Set wsCopySh3 = Sheets("Sheet3")
    Set wsPasteSh4 = Sheets("Sheet4")
    Dim lastRowSh4 As Long
    lastRowSh4 = ThisWorkbook.Sheets("Sheet4").Cells(Rows.Count, 3).End(xlUp).Row + 1
    Dim M As Long
    M = wsCopySh3.Range("c" & Rows.Count).End(xlUp).Row
    wsCopySh3.Range("c1:f" & M).Copy wsPasteSh4.Range("C" & lastRowSh4)

End Sub

Thanks that works ,
but i should of said, sum cells are formulas, is it possible to paste the values and not the formulas ?
Thanks
 
Upvote 0
This should do the job,
VBA Code:
Sub Paste_NextRow()

    Dim wsCopySh1 As Worksheet
    Dim wsPasteSh2 As Worksheet
    Set wsCopySh1 = Sheets("Sheet1")
    Set wsPasteSh2 = Sheets("Sheet2")
    Dim lastRowSh2 As Long
    lastRowSh2 = ThisWorkbook.Sheets("Sheet2").Cells(Rows.Count, 3).End(xlUp).Row + 1
    Dim N As Long
    N = wsCopySh1.Range("c" & Rows.Count).End(xlUp).Row
    wsCopySh1.Range("c1:f" & N).Copy
    wsPasteSh2.Range("C" & lastRowSh2).PasteSpecial Paste:=xlPasteValues
    
    '---------------------------------------
    
    Dim wsCopySh3 As Worksheet
    Dim wsPasteSh4 As Worksheet
    Set wsCopySh3 = Sheets("Sheet3")
    Set wsPasteSh4 = Sheets("Sheet4")
    Dim lastRowSh4 As Long
    lastRowSh4 = ThisWorkbook.Sheets("Sheet4").Cells(Rows.Count, 3).End(xlUp).Row + 1
    Dim M As Long
    M = wsCopySh3.Range("c" & Rows.Count).End(xlUp).Row
    wsCopySh3.Range("c1:f" & M).Copy
    wsPasteSh4.Range("C" & lastRowSh4).PasteSpecial Paste:=xlPasteValues

End Sub
 
Upvote 0
This should do the job,
VBA Code:
Sub Paste_NextRow()

    Dim wsCopySh1 As Worksheet
    Dim wsPasteSh2 As Worksheet
    Set wsCopySh1 = Sheets("Sheet1")
    Set wsPasteSh2 = Sheets("Sheet2")
    Dim lastRowSh2 As Long
    lastRowSh2 = ThisWorkbook.Sheets("Sheet2").Cells(Rows.Count, 3).End(xlUp).Row + 1
    Dim N As Long
    N = wsCopySh1.Range("c" & Rows.Count).End(xlUp).Row
    wsCopySh1.Range("c1:f" & N).Copy
    wsPasteSh2.Range("C" & lastRowSh2).PasteSpecial Paste:=xlPasteValues
   
    '---------------------------------------
   
    Dim wsCopySh3 As Worksheet
    Dim wsPasteSh4 As Worksheet
    Set wsCopySh3 = Sheets("Sheet3")
    Set wsPasteSh4 = Sheets("Sheet4")
    Dim lastRowSh4 As Long
    lastRowSh4 = ThisWorkbook.Sheets("Sheet4").Cells(Rows.Count, 3).End(xlUp).Row + 1
    Dim M As Long
    M = wsCopySh3.Range("c" & Rows.Count).End(xlUp).Row
    wsCopySh3.Range("c1:f" & M).Copy
    wsPasteSh4.Range("C" & lastRowSh4).PasteSpecial Paste:=xlPasteValues

End Sub

Thanks alot, thats exactly what i need
 
Upvote 0
I'm not getting you correctly, could you please explain a bit more? The last code (post #4) is pasting the values only without any formula, right?
 
Upvote 0
Sorry i will try to explain better,
Yes i only want to paste values , but macro keeps copying rows if it sees formula in columns C
Example row 20 to 40 column C has formulas, it still copys that them rows , which i dont want it to do
Thank for helping
 
Upvote 0
So, you mean column C20-C40 has the formula, but column d-e-f don't have any values for these rows, right?
 
Upvote 0

Forum statistics

Threads
1,215,042
Messages
6,122,810
Members
449,095
Latest member
m_smith_solihull

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