Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting formulas to code tofimoon4 New Users to Excel 4 October 11th 10 01:01 PM
converting cell formulaes to code Hein Excel Worksheet Functions 3 October 21st 08 10:43 AM
Converting EasyLanguage code to Excel holiday Excel Discussion (Misc queries) 0 January 6th 08 06:31 PM
Help converting code to late binding XP Excel Programming 2 February 16th 06 05:51 PM
Help Converting Cell Formula To VBA Code Minitman[_4_] Excel Programming 5 November 4th 04 08:03 PM


All times are GMT +1. The time now is 05:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"