Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Selected Cells Across Worksheets

Status
Not open for further replies.

vicky666

Programmer
Feb 13, 2003
22
GB
I am designing a mini system in Excel, and I want the user to be able to select any number of cells and when they click a button, their selected cells will be copied onto a seperate worksheet. I can get certain cells that i pre-define to tranfer over but can not work out how to transfer user selected cells as the selections are different every time. Any ideas?
 
Use the SELECTION object

Selection.copy destination:=sheets("Sheetname").range("a1")

If you use this, you should only select 1 cell as a destination range in case the cells are non contiguous - excel will paste over in the same pattern as it is copied Rgds
Geoff

Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur
 
When i run what you mentioned no data is copied across, it just blanks the destination cell. Can it be done by declaring a variable to store it in?
 
Have you changed "Sheetname" to be the name of your sheet that you want the data to be copied to ??

Code works fine for me otherwise although you can't run it on non-contiguous sets of data Rgds
Geoff

Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur
 
The selection object changes when the workbook/worksheet changes. Make sure you don't change activesheet away from the one which the user made the selection on before executing Geoff's code above.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top