copy data from WB1 to different WS's in WB2

picto

New Member
Joined
Apr 16, 2009
Messages
7
Hi All

I need to transfer data from a daily workbook to an archive workbook but put the data onto different worksheets depending on the value in column 1.

PHP:
eg
apple      data1      data2      data3
orange     data1      data2      data3
melon      data1      data2      data3
apple      data1      data2      data3

the data needs to go onto the next blank line on the worksheet named after each fruit. There are about 70 fruit to choose from.

Thanks
Shaun
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Something like this. Change the workbook names as required...

Code:
Sub Copy()
Dim i As Long
Dim LR As Long
Dim sh As String
With Workbooks("Book1.xls").Sheets("Sheet1")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
 
    For i = 2 To LR
        sh = .Cells(i, 1)
        Range(.Cells(i, 1), .Cells(i, 4)).Copy Workbooks("Book2").Sheets(sh).Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,799
Members
452,943
Latest member
Newbie4296

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