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 / Excel / New Users / December 2004

Tip: Looking for answers? Try searching our database.

VBA Command to Look at cell in an If statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wolf - 27 Dec 2004 17:13 GMT
I need to create a macro in VBA that will look at a specific cell (which
contains the result of a lookup formula) in an If statement.  Basically it
would look at a certian cell, and If that cell had the word "YES", then it
would execute a seprate macro.  If not, just continue on it merry way.

I have tried the following and several variations:

Sheets("Print Area").Select
Range("BO8:BO8").Select
If BO8 = YES Then Call PrintBatch

What the program has to do is look at the last entry made in a specific
column (hence the use of the Lookup formula in the cell) and if that entry
says "YES", then to execute the sub routine "PrintBatch".  I tried using
Frank Kabel's article on "Getting the Last Value in Range", but I seem to be
stuck on actually using the results of the selected cell and comparing it to
"YES".  Any help would be appreciated.  I have also ordered the 2 reference
books on VBA programing and commands noted in another thread, but they are
not due to be delivered until next week.

Thanks again for any help.
Don Guillett - 27 Dec 2004 17:57 GMT
try this from anywhere in the workbook. Notice the periods   .    !

with sheets("Print Area")
x=.cells(columns.count,8).end(xltoright).column
 if ucase(.cells("b",x))="YES" then PrintBatch
end with

Signature

Don Guillett
SalesAid Software
donaldb@281.com

> I need to create a macro in VBA that will look at a specific cell (which
> contains the result of a lookup formula) in an If statement.  Basically it
[quoted text clipped - 17 lines]
>
> Thanks again for any help.
Wolf - 27 Dec 2004 19:39 GMT
Don,

Thanks for your help.  For some reason when I did a cut and paste, the If
Ucase line kept coming back with a debug error.  I changed it a bit to:

With Sheets("Print Area")
    If UCase(.Cells(8, 67)) = "YES" Then PrintBatch
End With

So far it appears to do what I need it to do (keeps fingers crossed).  
Thanks again for all your help and have a safe and Happy New Year.

> try this from anywhere in the workbook. Notice the periods   .    !
>
[quoted text clipped - 27 lines]
> >
> > Thanks again for any help.
Don Guillett - 27 Dec 2004 23:27 GMT
That's cuz I goofed. Try with a period just before columns.count

x=.cells(.columns.count,8).end(xltoright).column
Signature

Don Guillett
SalesAid Software
donaldb@281.com

> Don,
>
[quoted text clipped - 39 lines]
> > >
> > > Thanks again for any help.
 
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.