Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Formula in worksheet.activate

Posted on 2013-12-09
8
Medium Priority
?
153 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 49

Assisted Solution

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

Assisted Solution

by:Martin Liss
Martin Liss earned 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

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

Accepted Solution

by:
Martin Liss earned 2000 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 49

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

704 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