ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy from worksheet (https://www.excelbanter.com/excel-programming/389494-copy-worksheet.html)

tom

copy from worksheet
 
Having the name of a worksheet in cell A1, I would like to extract
non-contiguous data from the sheet of that name and paste it onto my "Data
temp" sheet.
How can I get the data to extract from the named sheet onto the Data Temp
sheet?

Don Guillett

copy from worksheet
 
More info and layout

--
Don Guillett
SalesAid Software

"Tom" wrote in message
...
Having the name of a worksheet in cell A1, I would like to extract
non-contiguous data from the sheet of that name and paste it onto my "Data
temp" sheet.
How can I get the data to extract from the named sheet onto the Data Temp
sheet?



Gary''s Student

copy from worksheet
 
Sub move_it()
Dim ws As Worksheet
Set ws = Sheets(Range("A1").Value)
s = Array("B1", "Z1")
For i = LBound(s) To UBound(s)
ws.Range(s(i)).Copy Sheets("Data temp").Range(s(i))
Next
End Sub

Note that s is a string array that the contains the disjoint range to be
copied.
--
Gary''s Student - gsnu200722


tom

copy from worksheet
 
Works just as I had hoped!
Much appreciated Gary.

"Gary''s Student" wrote:

Sub move_it()
Dim ws As Worksheet
Set ws = Sheets(Range("A1").Value)
s = Array("B1", "Z1")
For i = LBound(s) To UBound(s)
ws.Range(s(i)).Copy Sheets("Data temp").Range(s(i))
Next
End Sub

Note that s is a string array that the contains the disjoint range to be
copied.
--
Gary''s Student - gsnu200722



All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com