ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB doesn't like this Formula? (https://www.excelbanter.com/excel-programming/361598-vbulletin-doesnt-like-formula.html)

DISMfish

VB doesn't like this Formula?
 
I don't understand why vb doesn't like this formula. Please help me
see what I am overlooking...

Dim Last_Column As Range
Set Last_Column = Worksheets(sName).Range("T2:T10")

Last_Column.Formula = "=IF(OR(" _
AND(" & Min_Limit & "<=Q2," & Max_Limit & "=Q2), _
AND(" & Min_Limit & "<=R2," & Max_Limit & "=R2), _
AND(" & Min_Limit & "=Q2," & Max_Limit & "<=R2)),1,0)"


Duncan[_5_]

VB doesn't like this Formula?
 
double quotations needed? ("""")


DISMfish

VB doesn't like this Formula?
 
Where?


Ardus Petus

VB doesn't like this Formula?
 
Last_Column.Formula = "=IF(OR(" & _
"AND(" & Min_Limit & "<=Q2," & Max_limit & "=Q2)," & _
"AND(" & Min_Limit & "<=R2," & Max_limit & "=R2)," & _
"AND(" & Min_Limit & "=Q2," & Max_limit & "<=R2)),1,0)"

HTH
--
AP

"DISMfish" a écrit dans le message de news:
...
I don't understand why vb doesn't like this formula. Please help me
see what I am overlooking...

Dim Last_Column As Range
Set Last_Column = Worksheets(sName).Range("T2:T10")

Last_Column.Formula = "=IF(OR(" _
AND(" & Min_Limit & "<=Q2," & Max_Limit & "=Q2), _
AND(" & Min_Limit & "<=R2," & Max_Limit & "=R2), _
AND(" & Min_Limit & "=Q2," & Max_Limit & "<=R2)),1,0)"




Xiazer[_11_]

VB doesn't like this Formula?
 

When trying to write a formula to a cell you need to double up on your
quotations

Last_Column.Formula = "=IF(OR(*""* _
AND(*""* & Min_Limit & *""*<=Q2,"" & Max_Limit & *""*=Q2), _
AND(*""* & Min_Limit &* ""*<=R2,*"" *& Max_Limit &* ""*=R2), _
AND(*""* & Min_Limit & *""*=Q2,*""* & Max_Limit & *""*<=R2)),1,0)"


When it puts the Formula in the cell it will remove the additional
quotes. remember only double quotes for the formula that will be in the
cell not around the formula. Hope THis Helps


--
Xiazer
------------------------------------------------------------------------
Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581
View this thread: http://www.excelforum.com/showthread...hreadid=542483


DISMfish

VB doesn't like this Formula?
 
Ok, I changed to the following, but I'm still getting an error...?

Last_Column.Formula = "=IF(OR( _
AND("" & RF_Min_Limit & ""<=Q2,"" & RF_Max_Limit & ""=Q2), _
AND("" & RF_Min_Limit & ""<=R2,"" & RF_Max_Limit & ""=R2), _
AND("" & RF_Min_Limit & ""=Q2,"" & RF_Max_Limit & ""<=R2)),1,0)"


Bob Phillips[_14_]

VB doesn't like this Formula?
 
I don't think it is double quotes that you need as I think Min_Limit and
Max_Limit are numbers.

Try

Dim Last_Column As Range
Set Last_Column = Worksheets(sname).Range("T2:T10")

Last_Column.Formula = "=IF(OR(" & _
"AND(" & Min_Limit & "<=Q2," & Max_Limit & "=Q2)," & _
"AND(" & Min_Limit & "<=R2," & Max_Limit & "=R2)," & _
"AND(" & Min_Limit & "=Q2," & Max_Limit & "<=R2)),1,0)"

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"DISMfish" wrote in message
oups.com...
Ok, I changed to the following, but I'm still getting an error...?

Last_Column.Formula = "=IF(OR( _
AND("" & RF_Min_Limit & ""<=Q2,"" & RF_Max_Limit & ""=Q2), _
AND("" & RF_Min_Limit & ""<=R2,"" & RF_Max_Limit & ""=R2), _
AND("" & RF_Min_Limit & ""=Q2,"" & RF_Max_Limit & ""<=R2)),1,0)"




DISMfish

VB doesn't like this Formula?
 
Thanks, that did it!


Tom Ogilvy

VB doesn't like this Formula?
 
You can't put a continuation character inside a string

s = "ABC _
EFG"

doesn't work.

s = "ABC" & _
"EFG"

--
Regards,
Tom Ogilvy


"DISMfish" wrote:

Ok, I changed to the following, but I'm still getting an error...?

Last_Column.Formula = "=IF(OR( _
AND("" & RF_Min_Limit & ""<=Q2,"" & RF_Max_Limit & ""=Q2), _
AND("" & RF_Min_Limit & ""<=R2,"" & RF_Max_Limit & ""=R2), _
AND("" & RF_Min_Limit & ""=Q2,"" & RF_Max_Limit & ""<=R2)),1,0)"



DISMfish

VB doesn't like this Formula?
 
Thanks, that did it!


DISMfish

VB doesn't like this Formula?
 
Where? What's the difference between single and double?

Thanks


DISMfish

VB doesn't like this Formula?
 
^ Please disregard the previous comment. It looks like there was a lag
in posting that comment.

Thanks Tom and Bob!


DISMfish

VB doesn't like this Formula?
 
Thanks, that did it!



All times are GMT +1. The time now is 02:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com