Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe Joe is offline
external usenet poster
 
Posts: 476
Default Macro ignores IF statement that refers to cell value

I have a macro that loops thru about 50 locations and gathers information.
In the interest of saving paper for a location with no data I don't want to
print the locations report. I have a cell that counts the values on the
sheet and only want to print if the count is greater than 0.

I have the following in the macro, where INVCOUNT is the range name that
counts cells with data and PRINTFORM is the macro that will print.

If INVCOUNT 0 Then PRINTFORM

The statement never seems to execute the PRINTFORM macro. However, if i
just do PRINTFORM it will print all locations.

What do I do?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Macro ignores IF statement that refers to cell value

ensure that you have
OPTION EXPLICIT
at the very top of your code sheet.
That will force you to specifically DIM all variables and ensures that VBA
won't simply treat INVCOUNT as a local variable. IN this case, it will
coerce to double with a zero value... hence the IF will never have a TRUE
value

"Joe" wrote in message
...
I have a macro that loops thru about 50 locations and gathers information.
In the interest of saving paper for a location with no data I don't want
to
print the locations report. I have a cell that counts the values on the
sheet and only want to print if the count is greater than 0.

I have the following in the macro, where INVCOUNT is the range name that
counts cells with data and PRINTFORM is the macro that will print.

If INVCOUNT 0 Then PRINTFORM

The statement never seems to execute the PRINTFORM macro. However, if i
just do PRINTFORM it will print all locations.

What do I do?


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
Macro ignores IF statement that refers to cell value Paul C Excel Programming 0 May 15th 09 09:05 PM
macro than refers to a cell? jackrobyn1 Excel Discussion (Misc queries) 1 June 18th 08 11:01 PM
Running macro in one workbook that refers to variable in another Andyjim Excel Programming 3 January 20th 08 07:09 PM
Formula/macro that ignores cells nonblanks pmarques Excel Discussion (Misc queries) 6 February 10th 06 02:55 PM
macro button refers to prev. workbook Maja Excel Programming 1 September 13th 03 03:09 AM


All times are GMT +1. The time now is 06:21 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"