Solved

Formula in worksheet.activate

Posted on 2013-12-09
8
144 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

710 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