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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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,215,463
Messages
6,124,962
Members
449,200
Latest member
indiansth

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