Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

IF Statement / Macro --- I tried!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CherylH - 26 Jul 2007 00:20 GMT
I need to create an IF statement and need some help!  I am building a table
and I need to look at the "status" column in order to insert the appropriate
value in the following column.

Here is what I want my IF statement to do (in English)!:

IF cell E2 = "Not Started", place a "1" in this cell
IF cell E2 = "Active", place a "2" in this cell
IF cell E2 = "Transferred", place a "3" in this cell
IF cell E2 = "Completed", place a "4" in this cell
  otherwise, keep <blank>

Now, I need this same thing to occur with all the cells that are populated
in column E - so, I would need the same "IF" statement to apply to "E3, E4,
etc".  IS there a way I can copy the actual formula and it will automatically
change to reflect the appropriate column number?

Any help would be appreciated!
Pranav Vaidya - 26 Jul 2007 08:38 GMT
do you want the formula to change the contents of the cell in which you are
entering the formula? I mean the formula is entered in E2 and you want 1 or 2
or 3 in the same cell?

Signature

Pranav Vaidya
VBA Developer
PN, MH-India

> I need to create an IF statement and need some help!  I am building a table
> and I need to look at the "status" column in order to insert the appropriate
[quoted text clipped - 14 lines]
>
> Any help would be appreciated!
CherylH - 26 Jul 2007 11:38 GMT
Hi Pranav, thanks for responding -
I want the resulting value (1,2,3,4) NOT in the same cell as I need to KEEP
these values "as is" --> it will be placed in the cell directly to the right
of it - in the following column (so, if looking at the value in E2, the
1,2,3,4 would be placed in F2, etc).

> > IF cell E2 = "Not Started", place a "1" in this cell
> > IF cell E2 = "Active", place a "2" in this cell
> > IF cell E2 = "Transferred", place a "3" in this cell
> > IF cell E2 = "Completed", place a "4" in this cell
> >    otherwise, keep <blank>

> do you want the formula to change the contents of the cell in which you are
> entering the formula? I mean the formula is entered in E2 and you want 1 or 2
[quoted text clipped - 18 lines]
> >
> > Any help would be appreciated!
Harold Druss - 26 Jul 2007 10:37 GMT
>I need to create an IF statement and need some help!  I am building a table
> and I need to look at the "status" column in order to insert the
[quoted text clipped - 17 lines]
>
> Any help would be appreciated!

Try this:

**************************************************************************
Sub CheckCell()
Dim iRow As Integer, iCol As Integer

iCol = 3

With ActiveDocument.Tables(1)
    For iRow = 1 To .Rows.Count
         Select Case Left(.Cell(iRow, iCol).Range.Text, Len(.Cell(iRow,
iCol).Range.Text) - 2)
              Case "Not Started"
                   .Cell(iRow, iCol).Range.Text = "1"
              Case "Active"
                   .Cell(iRow, iCol).Range.Text = "2"
              Case "Transferred"
                   .Cell(iRow, iCol).Range.Text = "3"
              Case "Completed"
                   .Cell(iRow, iCol).Range.Text = "4"
              Case Else
                   .Cell(iRow, iCol).Range.Text = ""
         End Select
    Next
End With

End Sub
****************************************************************************
Good luck
Harold
CherylH - 26 Jul 2007 11:40 GMT
Hi Harold,
I've never worked with this stuff before.  How and where do I place your
code in the Word document?  Thanks!

> >I need to create an IF statement and need some help!  I am building a table
> > and I need to look at the "status" column in order to insert the
[quoted text clipped - 48 lines]
> Good luck
> Harold
Graham Mayor - 26 Jul 2007 14:12 GMT
See http://www.gmayor.com/installing_macro.htm

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Hi Harold,
> I've never worked with this stuff before.  How and where do I place
[quoted text clipped - 52 lines]
>> Good luck
>> Harold
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.