View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Needs help converting some pseudo code into VB code


try

sub copyover()'UN tested
with sheet2
for i=2 to .cells(rows.count,"a").end(xlup).row
for j=sheet1.cells(sheet1.rows.count,"a").end(xlup).ro w+1
if .cells(i,"a")=5 and .cells(i,"b")=3 and .cells(i,"c")=4 then
sheet1.cells(j,"a").value=.cells(i,"f")
end with
next j
next i
end sub

--
Don Guillett
SalesAid Software

"williameis" wrote in message
ups.com...
I have a data sheet that looks something like this, with about 100,000
rows:

A B C D E F
1 5 3 5 3 2
9 5 4 3 5 3

From this data sheet I would like to extract the data point in column

F, anytime this criteria is met:
"A" = 5, "B"=3, and "C"=4

The mastersheet I am bringing data to (the sheet running the macro),
needs to keep track of the current cell and only move after a datapoint
is pulled. I have coded in other languages, but almost not at all in
basic. Here is the rough pseudo code I have drawn up, but I don't know
the actual function names to do this stuff and am having a hard time
looking it up (I keep running across ways to change the "Active" cell,
but I don't think I can use that in this case):

Dim i = 2 '// The current row in the data sheet - Sheet2
Dim J = 2 '// The current row in the master sheet - Sheet1
If (i<100,000) then
if(Sheet2.Cell(A,i)="5" && Sheet2.Cell(B,i)="3" &&
Sheet2.Cell(C,4)="4") then
Sheet1.Cell(A,J) = Sheet2.Cell(F,i)
J = J+1 '// Move 1 row down on the master sheet because we
had a positive match
End If
i = i+1
End If