Consulting

Results 1 to 6 of 6

Thread: help to write VBA code for ignoring cells with "0" in them (I'm new to this..)

  1. #1

    help to write VBA code for ignoring cells with "0" in them (I'm new to this..)

    how can I write a code that prints the cells from columns "A" and "B" into new columns but only the ones that the cells in column "c" are not zero in the same row ?


    A B C D
    20000 1.82 6 1547.4
    20010 1.83 0 0
    20020 1.83 0 0
    20030 1.83 42 10836
    20040 1.83 139 35862
    20050 1.83 145 37395.5
    20060 1.83 300 77400
    20070 1.83 100 25800
    20080 1.83 100 25800



  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Sub Basic()
    DIm Cel As Range
    
    For Each Cel in Range(Range("A1), Cells(Rows.Count, 1).End(xlUp))
    If Not Cel.Offset(0, 3) = 0 Then
    Cell.Resize(1, 2).Copy Cel.Offset(0,4)
    Next Cel
    End Sub
    Place the cursor inside a Keyword and Press F1 for help on the Keyword.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Sam,

    FYI you left out a close quote on (Range("A1),.

    Regards,

    BigDawg15

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    …and
    Cel.Offset(0, 2) = 0

  5. #5
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Just seeing if you guys are paying attention.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  6. #6
    Always alert if you are posting. LOL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •