PDA

View Full Version : Solved: Help with my code



ads_3131
07-05-2012, 02:03 AM
Hello

i have the vb below... how can i adapt this to look for any cell that contains a 0 in a specific column ? e.g column C?

-----------------------------------------

Sub CopyNonZero()

Dim v
j = 1

For i = 1 To 32
If Sheets("Sheet1").Cells(i, 1) <> 0 Then
v = Sheets("Sheet1").Cells(i, 1).EntireRow
Sheets("Sheet2").Cells(j, 1).EntireRow = v
j = j + 1
End If
Next i

End Sub

any help would be great ! :D

Aussiebear
07-05-2012, 02:06 AM
When posting code to the forum, please wrap it in vba tags

Bob Phillips
07-05-2012, 02:36 AM
You wouldn't adapt that code, you would write code that addresses the different requirement.

Find the first match, all matches? Do what once found?

ads_3131
07-05-2012, 02:53 AM
thanks xld.


for example.... i have on sheet1 three columns (A,B,C) of numbers.

With that code anything in column (A) that is blank or contains "0" isnt copied/removed on the copy to sheet2..... My question is how to manipulate this bit of code to point to column "B" or "C" instead of "A"?

Attached is an example with the macro that works for anything in column A...

ads_3131
07-05-2012, 02:56 AM
OOOO... sorry i have missed the obvious ! within the VBA next to the cell range the number representing the column. :D just needed to change that to the desired column number !