Copy cells with value <> 0 as a list

C

canvas

Hi,

I have a sheet with some cells with value 0 and others with data. I
want a macro that copies all the cells with value <>0 in other sheet
but as a list, one under the other. Is this possible?

Thanks!
 
G

Gary''s Student

Here is an example that you can adapt to your needs:

Sub moveUm()
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
s1.Activate
Set rr = ActiveSheet.UsedRange
n = 1
For Each r In rr
v = r.Value
If v <> 0 Then
s2.Cells(n, "A").Value = v
n = n + 1
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top