PDA

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



galad
11-12-2015, 09:11 AM
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

SamT
11-12-2015, 09:59 AM
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.

BigDawg15
11-12-2015, 02:37 PM
Sam,

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

Regards,

BigDawg15

p45cal
11-12-2015, 03:30 PM
…and
Cel.Offset(0, 2) = 0

SamT
11-12-2015, 06:28 PM
Just seeing if you guys are paying attention. :banghead:

BigDawg15
11-13-2015, 08:12 AM
Always alert if you are posting. LOL