Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default select all non-blank cells

I need a macro to select and copy all non-blank cells in Sheet1, then paste
these cells into sheet2 at Cell A1.

thanks much!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default select all non-blank cells

Try the below

Sub Macro()
Sheets("Sheet1").UsedRange.Copy Sheets("Sheet2").Range("A1")
End Sub

'If you have any formulas that are to be converted to values then try this
version
Sub Macro()
Sheets("Sheet1").UsedRange.Copy Sheets("Sheet2").Range("A1")
Sheets("Sheet2").UsedRange = Sheets("Sheet2").UsedRange.Value
End Sub

--
Jacob (MVP - Excel)


"johncaleb" wrote:

I need a macro to select and copy all non-blank cells in Sheet1, then paste
these cells into sheet2 at Cell A1.

thanks much!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default select all non-blank cells

Jacob

You seem to be assuming the used range is a block of contiguous cells only

If blanks are interspersed throughout the usedrange they will be copied
also.

OP might as well just copy sheet1 to sheet2


Gord Dibben MS Excel MVP


On Thu, 6 May 2010 08:31:02 -0700, Jacob Skaria
wrote:

Try the below

Sub Macro()
Sheets("Sheet1").UsedRange.Copy Sheets("Sheet2").Range("A1")
End Sub

'If you have any formulas that are to be converted to values then try this
version
Sub Macro()
Sheets("Sheet1").UsedRange.Copy Sheets("Sheet2").Range("A1")
Sheets("Sheet2").UsedRange = Sheets("Sheet2").UsedRange.Value
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default select all non-blank cells

Yes you are right. Not sure whether the OP meant to avoid blank
rows...eventhough its is mentioned as 'non-blank cells'

--
Jacob (MVP - Excel)


"Gord Dibben" wrote:

Jacob

You seem to be assuming the used range is a block of contiguous cells only

If blanks are interspersed throughout the usedrange they will be copied
also.

OP might as well just copy sheet1 to sheet2


Gord Dibben MS Excel MVP


On Thu, 6 May 2010 08:31:02 -0700, Jacob Skaria
wrote:

Try the below

Sub Macro()
Sheets("Sheet1").UsedRange.Copy Sheets("Sheet2").Range("A1")
End Sub

'If you have any formulas that are to be converted to values then try this
version
Sub Macro()
Sheets("Sheet1").UsedRange.Copy Sheets("Sheet2").Range("A1")
Sheets("Sheet2").UsedRange = Sheets("Sheet2").UsedRange.Value
End Sub


.

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
How to select blank cells only whilst using sumproduct Romileyrunner1 Excel Worksheet Functions 1 August 20th 09 07:48 AM
Up down arrow keys do not select cells if select locked cells unch roandrob Excel Discussion (Misc queries) 3 May 18th 09 12:48 AM
Can Excel automatically select print area on non-blank cells? N.F. Jackson[_2_] Excel Discussion (Misc queries) 1 April 3rd 09 07:03 PM
How To Select Blank Cells within a worksheet Roxanne Excel Discussion (Misc queries) 3 July 11th 07 09:38 PM
Select NON blank cells pcor New Users to Excel 8 September 18th 06 10:55 AM


All times are GMT +1. The time now is 09:13 AM.

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

About Us

"It's about Microsoft Excel"