Solved

Formula in worksheet.activate

Posted on 2013-12-09
8
141 Views
Last Modified: 2013-12-09
Folks,
I have a need to automatically enter into a cell a formula when the worksheet is activated.
This did not work:
ActiveSheet.Range("C6").Select
Range("C6") = B6 / A6

Open in new window

Once I have place to formula in the cell I need NOT to display it.
I've been using this code for to accomplish that:
Selection.NumberFormat = ";;;"

Open in new window


What is the correct coding I should use since the first failed bit of code failed.
0
Comment
Question by:Frank Freese
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 500 total points
ID: 39706920
Range("C6").Formula = "=B6 / A6"
0
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 500 total points
ID: 39706931
Please see this answer for two other ways to hide the formula.
0
 

Author Comment

by:Frank Freese
ID: 39706990
Almost there...
The value returned from the formula generates an ISERROR, which is what it is suppose to do.
I was hoping that I could apply the Select.NumberFormat=";;;" to hide the ISERROR display but that did not work.
When the worksheet is activated I do want to maintain the formulas, even with ISERROR but only display them when the user clicks on the "Display Data" command box.
This is a lesson on ISERROR on that workbook I've been working on.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Frank Freese
ID: 39707041
I could use conditional formatting and havew the font color white?
0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39707042
Try this formula instead
Range("C6").Formula = "=IF(ISERROR(B6 / A6),"" "",B6 / A6)"
0
 

Author Closing Comment

by:Frank Freese
ID: 39707152
You nailed it
Good job and many thanks
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 39707174
You're welcome and I'm glad I was able to help. Do you understand what the modified formula is doing?

Marty - MVP 2009 to 2013
0
 

Author Comment

by:Frank Freese
ID: 39707332
Yes I do understand.
If the formula generates an ISERROR then print "", else the solution.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question