Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Do...Loop syntax help?

Here is the current code I am using:

x = 2
Do Until Cells(x, 1).Value < ""
Cells(x, 5).Value = "IF(LOOKUP F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
x = x + 1
Loop

I am looking for the function to change relative to the current row...right
now in row 2 it is correct, but I would like the Lookup to change to F3 in
row 3, F4 in row 4 ect...

Any suggestions??


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Do...Loop syntax help?

Instead of looping, maybe use the FillDown method. something like this:

Dim lLastRow As Integer
lLastRow = Range("B65536").End(xlUp).Row
Range("B5").Value = "=IF(LOOKUP(F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
Range("B5:B" & lLastRow).FillDown


--
Hope that helps.

Vergel Adriano


"DB74" wrote:

Here is the current code I am using:

x = 2
Do Until Cells(x, 1).Value < ""
Cells(x, 5).Value = "IF(LOOKUP F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
x = x + 1
Loop

I am looking for the function to change relative to the current row...right
now in row 2 it is correct, but I would like the Lookup to change to F3 in
row 3, F4 in row 4 ect...

Any suggestions??


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Do...Loop syntax help?

Thank you for your reply Vergel...When I run this, it fills down to the end
of the sheet which I am trying to avoid, I just want it to fill down to the
end of my data (which varies)...any suggestion?

"Vergel Adriano" wrote:

Instead of looping, maybe use the FillDown method. something like this:

Dim lLastRow As Integer
lLastRow = Range("B65536").End(xlUp).Row
Range("B5").Value = "=IF(LOOKUP(F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
Range("B5:B" & lLastRow).FillDown


--
Hope that helps.

Vergel Adriano


"DB74" wrote:

Here is the current code I am using:

x = 2
Do Until Cells(x, 1).Value < ""
Cells(x, 5).Value = "IF(LOOKUP F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
x = x + 1
Loop

I am looking for the function to change relative to the current row...right
now in row 2 it is correct, but I would like the Lookup to change to F3 in
row 3, F4 in row 4 ect...

Any suggestions??


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Do...Loop syntax help?

This line

lLastRow = Range("B65536").End(xlUp).Row

should have determined the last row of data. Can you post the code that you
have now?


--
Hope that helps.

Vergel Adriano


"DB74" wrote:

Thank you for your reply Vergel...When I run this, it fills down to the end
of the sheet which I am trying to avoid, I just want it to fill down to the
end of my data (which varies)...any suggestion?

"Vergel Adriano" wrote:

Instead of looping, maybe use the FillDown method. something like this:

Dim lLastRow As Integer
lLastRow = Range("B65536").End(xlUp).Row
Range("B5").Value = "=IF(LOOKUP(F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
Range("B5:B" & lLastRow).FillDown


--
Hope that helps.

Vergel Adriano


"DB74" wrote:

Here is the current code I am using:

x = 2
Do Until Cells(x, 1).Value < ""
Cells(x, 5).Value = "IF(LOOKUP F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
x = x + 1
Loop

I am looking for the function to change relative to the current row...right
now in row 2 it is correct, but I would like the Lookup to change to F3 in
row 3, F4 in row 4 ect...

Any suggestions??


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Do...Loop syntax help?

I looked at your code again and I incorrectly used column B in my suggested
code.. try it like this instead:

Dim lLastRow As Long

lLastRow = Range("A65536").End(xlUp).Row
Range("E5").Value = "=IF(LOOKUP(F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
Range("E5:E" & lLastRow).FillDown



--
Hope that helps.

Vergel Adriano


"Vergel Adriano" wrote:

This line

lLastRow = Range("B65536").End(xlUp).Row

should have determined the last row of data. Can you post the code that you
have now?


--
Hope that helps.

Vergel Adriano


"DB74" wrote:

Thank you for your reply Vergel...When I run this, it fills down to the end
of the sheet which I am trying to avoid, I just want it to fill down to the
end of my data (which varies)...any suggestion?

"Vergel Adriano" wrote:

Instead of looping, maybe use the FillDown method. something like this:

Dim lLastRow As Integer
lLastRow = Range("B65536").End(xlUp).Row
Range("B5").Value = "=IF(LOOKUP(F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
Range("B5:B" & lLastRow).FillDown


--
Hope that helps.

Vergel Adriano


"DB74" wrote:

Here is the current code I am using:

x = 2
Do Until Cells(x, 1).Value < ""
Cells(x, 5).Value = "IF(LOOKUP F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING CRITERA'!A:A),0)"
x = x + 1
Loop

I am looking for the function to change relative to the current row...right
now in row 2 it is correct, but I would like the Lookup to change to F3 in
row 3, F4 in row 4 ect...

Any suggestions??




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Do...Loop syntax help?

I am looking for the function to change relative to the current row....

I see you have a solution. Here is just a technique...

Enter a working function in the spreadsheet.

Cells(x, 5).Value = "IF(LOOKUP F2,'SORTING


You will see that you are probably missing a "=" and "(".
Perhaps..."=IF(LOOKUP(F2,'SORTING...

Swithch from A1 display, to R1C1 Display, and copy that formula.

str = "=IF(LOOKUP(RC[1],...etc"

Then...
Cells(R, 5).FormulaR1C1 = str

Again, just a technique.
--
Dana DeLouis


"DB74" wrote in message
...
Here is the current code I am using:

x = 2
Do Until Cells(x, 1).Value < ""
Cells(x, 5).Value = "IF(LOOKUP F2,'SORTING
CRITERA'!B:B)=F2,LOOKUP(F2,'SORTING CRITERA'!B:B,'SORTING
CRITERA'!A:A),0)"
x = x + 1
Loop

I am looking for the function to change relative to the current
row...right
now in row 2 it is correct, but I would like the Lookup to change to F3 in
row 3, F4 in row 4 ect...

Any suggestions??




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
Syntax for stopping a Do Loop? bondjel Excel Discussion (Misc queries) 5 March 22nd 10 01:35 PM
Loop in a loop syntax Kirk P. Excel Programming 2 June 8th 07 05:59 PM
VBA Loop Case..If syntax okelly[_5_] Excel Programming 5 August 7th 06 03:24 PM
loop syntax Knox Excel Programming 2 May 17th 06 06:57 PM
"Loop until" syntax question Fastbike[_5_] Excel Programming 4 September 3rd 05 03:16 PM


All times are GMT +1. The time now is 09:45 AM.

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

About Us

"It's about Microsoft Excel"