ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to select cells with data (https://www.excelbanter.com/excel-programming/422061-code-select-cells-data.html)

lostandcondfused

Code to select cells with data
 

I cant seem to find any help for a code to select cells with data in it and
pasting them on to a different sheet. For example... I need Sheet1 to
autopopulate with data on sheets 2, 3 and 4 by clicking a button. But I only
want it to copy the cells that only have data/text in it and then paste it to
Sheet 1. Does anyone have an idea on how to go about doing this? I need help
really bad...

Michael

Code to select cells with data
 

First define the range you need to copy:
Set sSheet = Worksheets("Sheet1")
Set Scell = Range("A1:A5")
Then Destination:
Set dSheet = Worksheets("Sheet2")
Set Dcell = dSheet.Range("A2")
Then copy paste:
sCell.Copy
DCell.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=false
Application.CutCopyMode = False
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"lostandcondfused" wrote:

I cant seem to find any help for a code to select cells with data in it and
pasting them on to a different sheet. For example... I need Sheet1 to
autopopulate with data on sheets 2, 3 and 4 by clicking a button. But I only
want it to copy the cells that only have data/text in it and then paste it to
Sheet 1. Does anyone have an idea on how to go about doing this? I need help
really bad...



All times are GMT +1. The time now is 08:33 AM.

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