Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Worksheet If Statement in VBA

0 views
Skip to first unread message

Atif

unread,
Jan 6, 2010, 1:04:01 PM1/6/10
to
I am using following line of code:

Range("M" & vTargetRow).Formula = _
"=IF(AND(""F" & vTargetRow = "Standard Desktop"",""G" & vTargetRow =
"Standard 17" & """" & " Monitor""),1,"")"

Instead displaying 1 if condition true or <blank> if false, it fill
TargetCell with "FALSE".

IF statemetn is fine if directely entered in Worksheet
(=IF(AND(F500="Standard Desktop",G500="Standard 17"&""""&" Monitor"),1,""))

Bob Umlas

unread,
Jan 6, 2010, 1:32:11 PM1/6/10
to
Range("M" & vTargetRow).Formula "=IF(AND(F" & vTargetRow &"= ""Standard
Desktop"",G" & vTargetRow &"=""Standard 17"" & """""""" & ""
Monitor""),1,"""")"

"Atif" <At...@discussions.microsoft.com> wrote in message
news:1A38276B-3A2A-4DA9...@microsoft.com...

Barb Reinhardt

unread,
Jan 6, 2010, 1:42:01 PM1/6/10
to
This should help you. I had to split it up to figure it out.

Dim vTargetRow As Long
Dim myString As String
vTargetRow = 1
myString = "=IF(AND(F" & vTargetRow & "=""Standard Desktop"""
myString = myString & ", G" & vTargetRow & "=""Standard 17"""
myString = myString & """" & " Monitor""),1,"""")"

Debug.Print myString


Range("M" & vTargetRow).Formula = myString

--
HTH,

Barb Reinhardt

Atif

unread,
Jan 7, 2010, 5:55:01 PM1/7/10
to
mystring returns 19 Monitor19 Monitor

at traget cell it should be entered as
19 Monitor
19 Monitor

how to included Alt+Enter key using VBA

0 new messages