+ Reply to Thread
Results 1 to 6 of 6

ToggleButton to turn HasFormula off/on

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Question ToggleButton to turn HasFormula off/on

    Hi All

    I am hoping someone can help. I am using the following function along with some conditional formatting to show which cells in a range contain a formula:

    Please Login or Register  to view this content.
    But for some reason this causes the [Workbook_Open] and [Workbook_Activate] events not to trigger when the workbook is opened??

    I've been playing with several workarounds but think the easiest fix would be to toggle HasFormula on/off as needed. I've added a toggle button to the sheet:

    Please Login or Register  to view this content.
    But I can't figure out how to replace the message box with the HasFormula function?

    Any help would be greatly apprecaited

    Thanks all
    Vicky

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: ToggleButton to turn HasFormula off/on

    Hello
    Can you provide sample of your workbook and what are you trying to do?
    I don't think that the UDF will affect the events in this workbook module
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,301

    Re: ToggleButton to turn HasFormula off/on

    Quote Originally Posted by vwhite View Post
    ... But for some reason this causes the [Workbook_Open] and [Workbook_Activate] events not to trigger when the workbook is opened?? ...
    1. What does it mean ? What did you want to do ?
    2. Rename the function - HasFormula is reserved word in vba.
    3. In some cases you will have a different result than you would like (you will get "0"), because ... - see info from the context help function:
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: ToggleButton to turn HasFormula off/on

    Quote Originally Posted by YasserKhalil View Post
    Hello
    Can you provide sample of your workbook and what are you trying to do?
    I don't think that the UDF will affect the events in this workbook module
    Hi YasserKhalil

    Sorry about this, I', having trouble uploading the workbook
    It was about 3,500KB
    But I got it down to 2,300 after removing any sensitive data and putting it in a zip file

    The max file size for zips is 9.77MB so it should be working but keeps saying 'Upload failed'
    I tried 3 different web browsers?

    I will persevere and keep you posted

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: ToggleButton to turn HasFormula off/on

    First keep just some little rows in your file so as to make it smaller in size then compress the file in ZIP format if you find it still bigger

  6. #6
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: ToggleButton to turn HasFormula off/on

    Quote Originally Posted by YasserKhalil View Post
    Hello
    Can you provide sample of your workbook and what are you trying to do?
    I don't think that the UDF will affect the events in this workbook module
    Ok I've got it. File now uploaded
    And I've also made a curious discovery about precisely when this issue occurs

    I use the attached spreadsheet to process invoices onto Sage.
    The main sheet "INV & CRN" has conditional formatting in columns G:G and N:P to change the background colour of any cells containing a formula.

    This conditional formatting is linked to the HasFormula VBA function in module 4

    While the HasFormula function is present, none of the code in 'This Worksheet' section triggers when the workbook is opened?
    Workbook_Open() never runs
    And Woorkbook_Activate() only runs if you open another workbook then tab back to this one

    However, if you go to module 4, comment out the code, save, close and re-open the workbook, both jobs (Workbook_Open and Workbook_Activate) run immediately as the workbook opens

    Also I have just made a little discovery.
    My macro security settings are set to "Enable All Macros" but if you change them to "Disable all Macros With Notification" when you download and open the workbook for the first time, and you see the yellow message bar along the top saying "Security Warning. Some active content has been disabled. Click for more details. [Enable Content]" , after clicking enable that first time, everything works perfectly. Both Workbook_Open and Workbook_Activate codes fire, and the HasFormla colour formatting is on.

    But if you close the workbook and reopen it, it reverts back to not working

    If there is any way to toggle the HasFormula on/off (as that's what seems to be what's causing the problem when opening) it would be so helpful

    Much appreciated
    Vicky
    Attached Images Attached Images
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Changing the cell.HasFormula to another formula WITH CONDITION
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-29-2016, 02:16 PM
  2. [SOLVED] Insert EntireRow (above of) if cell/s below HasFormula
    By ykobure in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-02-2015, 08:41 AM
  3. [SOLVED] HasFormula to find only specific formulas
    By strud in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-25-2014, 12:45 PM
  4. simple... HasFormula ?
    By mark kubicki in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-11-2006, 11:10 AM
  5. Help with ActiveCell.HasFormula
    By Paul Fenton in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2006, 10:10 AM
  6. HasFormula
    By John Wirt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2006, 12:10 AM
  7. [SOLVED] HasFormula protect cell
    By SIGE in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-19-2005, 01:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1