Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Needs help converting some pseudo code into VB code
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Needs help converting some pseudo code into VB code
Thanks - that was just what I needed! I just didn't know the functions
and was able to make a couple small changes to what you had to get it working. Here is the finished product if anyone is interested: Sub copyover() 'UN tested With Sheet2 Dim j j = 1 For i = 2 To .Cells(Rows.Count, "a").End(xlUp).Row 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 If j = j + 1 Next i End With End Sub Don Guillett wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
converting formulas to code | New Users to Excel | |||
converting cell formulaes to code | Excel Worksheet Functions | |||
Converting EasyLanguage code to Excel | Excel Discussion (Misc queries) | |||
Help converting code to late binding | Excel Programming | |||
Help Converting Cell Formula To VBA Code | Excel Programming |