Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Wolf
 
Posts: n/a
Default VBA Command to Look at cell in an If statement

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.


  #3   Report Post  
Wolf
 
Posts: n/a
Default

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.
"Don Guillett" wrote:

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

--
Don Guillett
SalesAid Software

"Wolf" wrote in message
...
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.





  #4   Report Post  
Don Guillett
 
Posts: n/a
Default

That's cuz I goofed. Try with a period just before columns.count

x=.cells(.columns.count,8).end(xltoright).column
--
Don Guillett
SalesAid Software

"Wolf" wrote in message
...
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.
"Don Guillett" wrote:

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

--
Don Guillett
SalesAid Software

"Wolf" wrote in message
...
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.







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
Maintaining cell reference after sorting GRITS Excel Discussion (Misc queries) 2 April 30th 23 07:42 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. QUEST41067 Excel Discussion (Misc queries) 1 January 15th 05 10:29 PM
How do I link many cells to one particular cell? fish@divi Excel Discussion (Misc queries) 2 January 5th 05 12:00 AM
Addition to Turn cell red if today is greater or equal to date in cell Rich New Users to Excel 2 December 9th 04 03:06 AM
Unable to set the active cell from VBA HMS New Users to Excel 1 December 7th 04 10:56 PM


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

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"