Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using IF Formula


I would like to use the IF Formula to check the contents of a cell and
place a "Yes" if true or nothing if False. The standard formula of IF
(A27=0,"Yes","") doesn't work in VBA because of the quotation marks for
some reason. How do I do it?

Also, I would like to counter the rows by 14 and place the result in a
column. In other words, check A27 and place the result in H1 on
Sheet3. Then check A41 and place the result in H2 and so on. Thanks.
Tom - you've been a huge help!! I unfortunately learn by example - I
wish there was a site or reference materials available that catered to
the very beginner! Thanks again!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Using IF Formula

Try using the help button.

But the "IF method" is

IF question (range("A27") = 0) then
pass condition (range("A27") = "Yes")
Else
failcondition (nothing)
end if

note: you do not need the else part also when you look up
the "For method" you might like to use the "step" part at
the end.

Jase

The best way to learn syntax is to have a go and try to
debug the error.

-----Original Message-----

I would like to use the IF Formula to check the contents

of a cell and
place a "Yes" if true or nothing if False. The standard

formula of IF
(A27=0,"Yes","") doesn't work in VBA because of the

quotation marks for
some reason. How do I do it?

Also, I would like to counter the rows by 14 and place

the result in a
column. In other words, check A27 and place the result

in H1 on
Sheet3. Then check A41 and place the result in H2 and so

on. Thanks.
Tom - you've been a huge help!! I unfortunately learn by

example - I
wish there was a site or reference materials available

that catered to
the very beginner! Thanks again!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Using IF Formula

Copy tis into a VBA module so you can read it


Sub NS()
Dim R As Long, LR As Long, S3r
'S3r is sheet3 row x
'Application.ScreenUpdating = False 'makes the macro run
faster by not updating video
'you may want to comment out the above line if you want to
watch the macro run
ActiveSheet.Cells.SpecialCells
(xlCellTypeLastCell).Activate 'Finds the last cell in the
WS so the loop knows when to stop
LR = ActiveCell.Row 'Address of the last row in the WS
Range("A1").Select 'Change A1 to the cell address you want
the loop to start at
S3r = 1
Do
If ActiveCell.Value = 0 And ActiveCell.Value < "" Then
Worksheets("Sheet3").Range("H" & S3r).Value = "Yes" 'put
the value "yes" in cloumn H row x
ActiveCell.Offset(14).Activate 'moves the cursor (active
cell) 14 rows down
R = ActiveCell.Row 'Sets R = to the current row so we can
test if the loop should continue
S3r = S3r + 1
Else
ActiveCell.Offset(14).Activate 'moves the cursor (active
cell) 14 rows down
R = ActiveCell.Row
End If
Loop Until R = LR Or R LR
End Sub

Marty

-----Original Message-----

I would like to use the IF Formula to check the contents

of a cell and
place a "Yes" if true or nothing if False. The standard

formula of IF
(A27=0,"Yes","") doesn't work in VBA because of the

quotation marks for
some reason. How do I do it?

Also, I would like to counter the rows by 14 and place

the result in a
column. In other words, check A27 and place the result

in H1 on
Sheet3. Then check A41 and place the result in H2 and so

on. Thanks.
Tom - you've been a huge help!! I unfortunately learn by

example - I
wish there was a site or reference materials available

that catered to
the very beginner! Thanks again!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Using IF Formula

It rather depends on (a) you want the answer to change if
the data changes ie you want the formula in the cell, or
(b) you want VBA to enter the result

In the example, rw and cl are lomg and represent the
address of the cell to be tested. "B5" then is rw=5, cl=2
and the answer is placed one column to the right

(a) place a formula:-

Cells(rw, cl + 1).FormulaR1C1 = _
"=IF(RC[-1]=0,""Yes"","""")"

(b) use VBA to set the answer:-
If Cells(rw, cl).Value = 0 Then
Cells(rw, cl + 1) = "Yes"
End If


Patrick Molloy
Microsoft Excel MVP








-----Original Message-----

I would like to use the IF Formula to check the contents

of a cell and
place a "Yes" if true or nothing if False. The standard

formula of IF
(A27=0,"Yes","") doesn't work in VBA because of the

quotation marks for
some reason. How do I do it?

Also, I would like to counter the rows by 14 and place

the result in a
column. In other words, check A27 and place the result

in H1 on
Sheet3. Then check A41 and place the result in H2 and

so on. Thanks.
Tom - you've been a huge help!! I unfortunately learn

by example - I
wish there was a site or reference materials available

that catered to
the very beginner! Thanks again!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Using IF Formula

Try "Immediate If"
MyValue = IIF(A27=0,"Yes","No")

Regards
BrianB
=============================================

Novice wrote in message ...
I would like to use the IF Formula to check the contents of a cell and
place a "Yes" if true or nothing if False. The standard formula of IF
(A27=0,"Yes","") doesn't work in VBA because of the quotation marks for
some reason. How do I do it?

Also, I would like to counter the rows by 14 and place the result in a
column. In other words, check A27 and place the result in H1 on
Sheet3. Then check A41 and place the result in H2 and so on. Thanks.
Tom - you've been a huge help!! I unfortunately learn by example - I
wish there was a site or reference materials available that catered to
the very beginner! Thanks again!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using IF Formula


"Novice" wrote in message
...

I would like to use the IF Formula to check the contents of a cell and
place a "Yes" if true or nothing if False. The standard formula of IF
(A27=0,"Yes","") doesn't work in VBA because of the quotation marks for
some reason. How do I do it?

Also, I would like to counter the rows by 14 and place the result in a
column. In other words, check A27 and place the result in H1 on
Sheet3. Then check A41 and place the result in H2 and so on. Thanks.
Tom - you've been a huge help!! I unfortunately learn by example - I
wish there was a site or reference materials available that catered to
the very beginner! Thanks again!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


If you want to use VB to put a formula in a cell, the formula must be
surrounded by double quotes since it is text. Since the IF requires double
quotes within the formula, you need to use double double quotes. Maybe this
example makes more sense:

Range("A28").formula = "=if(A27=0,""Yes"","""") "

--Kiloran


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
Commenting custom formula fields/formula on formula editor Muxer Excel Programming 2 July 24th 03 01:02 AM


All times are GMT +1. The time now is 10:10 PM.

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

About Us

"It's about Microsoft Excel"