Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JD JD is offline
external usenet poster
 
Posts: 7
Default Copy non blank cells to another worksheet

HI, can anyone point out why this isn't working?

Sub CopyDataOnly()

Sheets("Sheet1").Range("A10:A100").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Copy
Sheets("Sheet2").Select
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub

I end up getting an error after "Selection.Copy".

Basically I'm looking to select all cells with data and move them to
another worksheet and paste them.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Copy non blank cells to another worksheet

Hi JD,

Try the following version which avoids selections:

'=============
Sub CopyDataOnly()
On Error Resume Next
Sheets("Sheet1").Range("A10:A100"). _
SpecialCells(xlCellTypeConstants, 23).Copy
Sheets("Sheet2").Range("A10").PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
On Error GoTo 0
Application.CutCopyMode = False
End Sub
'<<=============

Selections are rarely necessary or desirable.

---
Regards,
Norman



"JD" wrote in message
oups.com...
HI, can anyone point out why this isn't working?

Sub CopyDataOnly()

Sheets("Sheet1").Range("A10:A100").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Copy
Sheets("Sheet2").Select
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub

I end up getting an error after "Selection.Copy".

Basically I'm looking to select all cells with data and move them to
another worksheet and paste them.



  #3   Report Post  
Posted to microsoft.public.excel.programming
JD JD is offline
external usenet poster
 
Posts: 7
Default Copy non blank cells to another worksheet


Norman Jones wrote:
Hi JD,

Try the following version which avoids selections:

'=============
Sub CopyDataOnly()
On Error Resume Next
Sheets("Sheet1").Range("A10:A100"). _
SpecialCells(xlCellTypeConstants, 23).Copy
Sheets("Sheet2").Range("A10").PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
On Error GoTo 0
Application.CutCopyMode = False
End Sub
'<<=============

Selections are rarely necessary or desirable.


Thanks Norman, that works a treat.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy cell value into blank cells below (full worksheet) SimmoG Excel Worksheet Functions 4 June 3rd 09 11:03 PM
copy data from one worksheet and disregard blank cells Allan Excel Discussion (Misc queries) 6 October 20th 08 07:40 AM
Copy Data from Row 1 to last blank row in next worksheet MyKeyJ Excel Worksheet Functions 1 December 28th 07 09:25 PM
Where are the examples from Help to copy to a blank worksheet? Beanbabeehoohoo Excel Discussion (Misc queries) 1 May 18th 06 10:10 AM
Macro copy and paste = blank worksheet efface Excel Discussion (Misc queries) 1 April 27th 06 09:52 PM


All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"