Macro copy data from multi sheets to other sheet

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
471
Office Version
  1. 365
Platform
  1. Windows
Hi would any on have a macro code that would copy data from sheets 6,7,8,9,10 cells A70 to F130 to the next available row on a sheet called 'DATA'
My sheet names are just 6,7,8,9,10
Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Glad you sorted it & thanks for the feedback.
 
Upvote 0
Glad you sorted it & thanks for the feedback.
VBA Code:
   For i = 6 To 10
      With Sheets(CStr(i))
         If LCase(.Range("Z1").Value) = "yes" Then
            .Range("A70:F130").Copy Sheets("Data").Range("A" & Rows.Count).End(xlUp).Offset(1)
        elseif LCase(.Range("Z1").Value) = "no" Then
            .Range("A70:F130").Copy Sheets("Nodata").Range("A" & Rows.Count).End(xlUp).Offset(1)
        elseif LCase(.Range("Z1").Value) = "mabye" Then
            .Range("A70:F130").Copy Sheets("Maybe").Range("A" & Rows.Count).End(xlUp).Offset(1)
         End If
      End With
   Next i
End Sub

Is there a way to copy data to another workbook called 'moved' ?
 
Upvote 0
Yes, like
VBA Code:
If LCase(.Range("Z1").Value) = "yes" Then
            .Range("A70:F130").Copy Workbooks("Moved.xlsx").Sheets("Data").Range("A" & Rows.Count).End(xlUp).Offset(1)
The other workbook will need to be open.
 
Upvote 0
Yes, like
VBA Code:
If LCase(.Range("Z1").Value) = "yes" Then
            .Range("A70:F130").Copy Workbooks("Moved.xlsx").Sheets("Data").Range("A" & Rows.Count).End(xlUp).Offset(1)
The other workbook will need to be open.
Thanks ill give it a go
 
Upvote 0
Nothing copies to other workbook
I have other workbook open
EDIT - Fixed workbook 'Moved' can not be macro enabled for it to work

VBA Code:
Sub ste33uka()
   Dim i As Long
 
   For i = 1 To 20
      With Sheets(CStr(i))
         If LCase(.Range("Z1").Value) = "yes" Then
            .Range("A70:F130").Copy Workbooks("Moved.xlsx").Sheets("Data").Range("A" & Rows.Count).End(xlUp).Offset(1)
         ElseIf LCase(.Range("Z1").Value) = "no" Then
            .Range("A70:F130").Copy Workbooks("Moved.xlsx").Sheets("NoData").Range("A" & Rows.Count).End(xlUp).Offset(1)
         End If
      End With
   Next i
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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