Need help copy range >0

Lukums

Board Regular
Joined
Nov 23, 2015
Messages
195
G'day,

I'm trying to copy this table and paste into another sheet.

Let's say this example is Column A and Column B (sheet1)

The paste into another sheet is fine and I'm across that but I'm having trouble selecting the range where zeros are NOT present.

350012
45206
210092
00
00

<tbody>
</tbody>

So the solution would be:

350012
45206
210092

<tbody>
</tbody>

Thanks all!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Filter the zeroes, select with F5(Goto)-Special-Visible cells only, then copy & paste.
 
Last edited:
Upvote 0
Filter the zeroes, select with F5(Goto)-Special-Visible cells only, then copy & paste.

Thought about that!

But! If I use .autofilter cell (whatever) = >0
and then autofilter = false

It unhides all my hidden rows so basically only 31 rows are visible up to column BB
 
Upvote 0
Hi Lukums
Does this do what you want...

Code:
Sub MM1() 'no header row
 With ActiveSheet.UsedRange
            .AutoFilter
            .AutoFilter field:=1, Criteria1:=">0"
            .Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy Sheets("Sheet2").Range("A1")
            .AutoFilter
    End With
End Sub
 
Upvote 0
Hi Lukums
Does this do what you want...

Code:
Sub MM1() 'no header row
 With ActiveSheet.UsedRange
            .AutoFilter
            .AutoFilter field:=1, Criteria1:=">0"
            .Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy Sheets("Sheet2").Range("A1")
            .AutoFilter
    End With
End Sub

You're probably right as rain (as always) however I think! If I do, do it this way I will need to find the last entry in column A and paste below.
But I'll recheck this iteration and get back to you asap! As always thank you!
 
Upvote 0
Maybe this then

Code:
Sub MM1() 'no header row
 Dim LR As Long
 LR = Sheets("Sheet2").Cells.SpecialCells(xlCellTypeLastCell).Row + 1
 With ActiveSheet.UsedRange
            .AutoFilter
            .AutoFilter field:=1, Criteria1:=">0"
            .Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy Sheets("Sheet2").Range("A" & LR)
            .AutoFilter
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,391
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top