LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default copy range of cells with blanks then paste without blanks

That was it. I have tested it and it works. Thanks again for your help.

Rob


"Ron de Bruin" wrote:

The example loop through row 1 to 1000

StartRow = 1
EndRow = 1000


You can use this for example to loop through all rows in column A with data

StartRow = 1
EndRow = .Cells(.Rows.Count, "A").End(xlUp).Row

It use the A column now, so change the A to your column


and the "C1" to "WasteD"

That is OK


For more info see
http://www.rondebruin.nl/delete.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl



"justaguyfromky" wrote in message
...
Ron,

I came up with a problem when I tried to change the macro to match my data.
The range of cells that I am using is named. The named range may grow
because I have another macro that will insert a new row to add new data. So
in theory, I changed the "A's" in the formula to "Waste" (the name of the
range) and the "C1" to "WasteD" (the destination of the copied cells).
"WasteD" is a single cell. Is this still possible?

Thanks,
Rob

"Ron de Bruin" wrote:

Hi justaguyfromky

With the formulas on A1:A1000 this example copy to C1

Sub UnionExample()
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim StartRow As Long
Dim EndRow As Long
Dim rng As Range

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 1000

For Lrow = StartRow To EndRow Step 1

If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "A").Value < "" Then
If rng Is Nothing Then
Set rng = .Cells(Lrow, "A")
Else
Set rng = Application.Union(rng, .Cells(Lrow, "A"))
End If
End If

Next
End With

If Not rng Is Nothing Then rng.Copy Range("C1")

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub

Another option is to use EasyFilter
http://www.rondebruin.nl/easyfilter.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl



"justaguyfromky" wrote in message
...
I have a range of cells that have values in some cells and blank in others
(actually there is a formula in all cells, but if there is no value, the
formula returns nothing but a blank cell). I want to copy that range of
cells and paste it in a column without pasting the blank cells. So the copy
range may be 40 cells, but the paste range may only be 15 or 20. How can I
paste this into the destination cells leaving no blanks? Any help would be
greatly appreciated. Thanks, Rob






 
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 & Paste Non Blanks Only Igorin Excel Discussion (Misc queries) 2 January 28th 09 01:33 PM
Copy & Paste Non Blanks Only Igorin Excel Worksheet Functions 4 January 28th 09 01:28 PM
copy range of cells with blanks then paste without blanks justaguyfromky Excel Worksheet Functions 1 September 3rd 06 07:56 PM
Paste Special Skip Blanks not skipping blanks, but overwriting... gsrosin Excel Discussion (Misc queries) 0 February 22nd 05 03:33 AM
copy / paste without skipping blanks Todd Excel Programming 2 June 18th 04 12:55 AM


All times are GMT +1. The time now is 01:34 AM.

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"