Invalid qualifier

  • Thread starter Thread starter Martin Wheeler
  • Start date Start date
M

Martin Wheeler

xl2000
XL does not like the code below
"A" is rejected as an invalid qualifier.
Can someone please set me straight. I have read the Help section but it
does not make sense to me.
Ta,
Martin

Dim A As Single
A = Application.WorksheetFunction.Max(.Range("CA7:CA9"))
Set B = A.Offset(0, 6)
Set C = A.Offset(0, 5)
Set D = A.Offset(0, 8)
If A > 10 And B = .Range("CG32").Value And C < 20 And D < -0.395 Then
 
Martin,
Dim A As Single
A = Application.WorksheetFunction.Max(.Range("CA7:CA9"))

Here you are declaring A sa Single and define it as the maximum value of the
range CA7:CA9, let's say A=35
Set B = A.Offset(0, 6)
Set C = A.Offset(0, 5)
Set D = A.Offset(0, 8)

....and here you are trying to use the variable A as a range, hence

if A=35, then 35.Offset(0,6) = NONSENSE

KL
 
A is defined as a Single variable, and you are trying to use it as a range.
You need to get the cell that contains that Max value, something akin to

Dim A As Single
Dim APos as Long
DimARng as Range

A = Application.WorksheetFunction.Max(.Range("CA7:CA9"))
APos = WorksheetFunction.Match(A1,.Range("CA7:CA9"),0)
Set ARng = .Range("CA7:CA9").Cells(APos,1)
Set B = ARng.Offset(0, 6)
Set C = ARng.Offset(0, 5)
Set D = ARng.Offset(0, 8)
If A > 10 And B = .Range("CG32").Value And C < 20 And D < -0.395 Then

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Hi Bob,
Thanks for the help Bob, I had to play with the code a bit and it still
needs some fine tuning but it does run.
Ta,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top