Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Worksheet If Statement in VBA

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,""))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default Worksheet If Statement in VBA

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

"Atif" wrote in message
...
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,""))


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Worksheet If Statement in VBA

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" wrote:

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,""))

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Worksheet If Statement in VBA

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
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
If statement to go through every worksheet Damian Excel Discussion (Misc queries) 1 February 6th 10 02:55 AM
If statement to copy an entire row to other worksheet w/ in same b hshayh0rn Excel Worksheet Functions 7 May 1st 09 09:05 PM
Set statement for non active worksheet Jim at Eagle Excel Programming 2 April 29th 08 08:49 PM
if statement in worksheet CarolC Excel Worksheet Functions 5 June 1st 05 08:35 PM
Worksheet code if-color-statement Jonsson[_43_] Excel Programming 1 September 29th 04 03:57 PM


All times are GMT +1. The time now is 12:39 AM.

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

About Us

"It's about Microsoft Excel"