Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One Before Max

Status
Not open for further replies.

JoeMicro

Technical User
Aug 24, 2007
76
CA
Hi, is there a way i could get in vba one before the max of a field?

ex.
Column
2500
3200
1500
5700

so i want to able to get into a variable 3200, and then 2500, etc.. basically i should be able to specify how for backwards from the max i want to go..

i hope his makes any sense.

Any ideas??

Joe.
 


hi,

in VBA? Why not using SQL?
Code:
select max(a.column)
from [Your Table] a
having max(a.column) < (select Max(b.column) from [Your Table] b)
[code]


Skip,
[sub]
[glasses]Just traded in my [b]old subtlety[/b]...
for a [b]NUANCE![/b][tongue][/sub]
 
Because i need to pull it into a loop and play with each one individually.

and just sorting the table in order and looping through it will make things more complicated..

let me try to explain the concept i am trying to do, maybe that will help...

i have this quantity ex 75843 i want to divide that into the highest factor ex. 3200 the rest i will divide into 2500 and so on. ad i need to do it in vba because the 75843 is created on the fly based on other vba calculations, so i don't think that a query will do the job.
 
SQL would still do in this case.
Pull something like this into a recordset:
Code:
Select [yourcolumn]
From [$Sheet1]
Order by [yourcolumn] DESC

Then start looping from the second entry of the recordset.

Cheers,
MakeItSo

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top