Macro transfer data from a column with a twist

Elfiraon

New Member
Joined
Sep 10, 2014
Messages
31
Hey all,

I'm trying to create a macro that will do the following:

When macro is activated; In a column (eg. column A) go to the first cell that has a value other than "0" and then copy, then keep going down cell by cell until it finds a blank cell, once the values are selected, copy and paste them in a different column (eg. column B or column A of different sheet).

Any input/help is appreciated, thanks!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try this:

Code:
Option Explicit


Sub copyZero()
    Dim lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Dim newR As Long
    Dim i As Long
    
    Application.ScreenUpdating = False
    For i = 1 To lr
    newR = Range("B" & Rows.Count).End(xlUp).Row
    If Range("A" & i) <> 0 Then
    Range("A" & i).Copy Range("B" & newR + 1)
    End If
    Next i
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "complete"


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

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