Excel 2003 copy only positive numbers of a list and paste to new column

I have a list of positive and negative numbers in column C. I want to extract only the positive numbers to a new column E. A formula or VBA  for excel 2003 would be nice
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


pls try

Sub Macro1()

    ActiveSheet.Range("A1:A100").AutoFilter Field:=1, Criteria1:=">0", _
    Range("A1:A100").Copy Range("E1")
End Sub

Open in new window

Glen RichmondSenior Software Developer.Commented:
Hard coding the range ("A1:A100") will limit the scalability and dynamism of the code.. You need the code to dynamically adapt to more rows.
Mabye concatenate on the UsedRange.Rows.Count into Rgonzo's solution?

I just wrote this alternative that can be added to any module and tailored to use ..

Sub RemoveNegs()
    'set up obj var to sheet
    Dim wrkSht As Excel.Worksheet
    Dim intSource As Integer
    Dim intTarget As Integer
    'set up row e target row starting value
    intTarget = 1
    'set obj to sheet
    Set wrkSht = Application.Worksheets("Sheet1")
    'loop through all rows used
    For intSource = 1 To wrkSht.UsedRange.Rows.Count
        'is the number posertive?
        If wrkSht.Cells(intSource, "C").Value >= 0 Then
            'place value into target row E
            wrkSht.Cells(intTarget, "E").Value = wrkSht.Cells(intSource, "C").Value
            'add next row for target row (E)
            intTarget = intTarget + 1
        End If
End Sub

Open in new window

Hope this helps?
then try

Sub Macro1()
    Set myRange = Range("C1:C" & Range("C" & Rows.Count).End(xlUp).Row)
    myRange.AutoFilter Field:=1, Criteria1:=">0", _
    myRange.Copy Range("E1")
End Sub


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.