+ Reply to Thread
Results 1 to 4 of 4

Is Excel is now going out of it's way to mess me around?

  1. #1
    Registered User
    Join Date
    06-07-2006
    Posts
    3

    Is Excel is now going out of it's way to mess me around?

    How come this works?

    if I place this formula in a cell

    =IF(A1 <> "",ResetFont())


    And in Module1 the Subroutine is

    Sub ResetFont()
    msgBox(ActiveCell.Value)
    End sub


    BUT this doesnt?

    Sub ResetFont()
    ActiveCell.Font.Size = 10
    End sub


    Also if I try


    Sub ResetFont()
    ActiveCell.Value = "1"
    End sub

    It throws an error in the cell with the =IF(...?

  2. #2
    Chip Pearson
    Guest

    Re: Is Excel is now going out of it's way to mess me around?

    The first one works because the Sub doesn't attempt to change any
    property of Excel.


    "Willot" <Willot.29230y_1149723901.9727@excelforum-nospam.com>
    wrote in message
    news:Willot.29230y_1149723901.9727@excelforum-nospam.com...
    >
    > HOW COME THIS WORKS?
    > if I place this formula in a cell
    >
    > =IF(A1 <> "",ResetFont())
    >
    >
    > And in Module1 the Subroutine is
    >
    > Sub ResetFont()
    > msgBox(ActiveCell.Value)
    > End sub
    >
    >
    > BUT THIS DOESNT?
    > Sub ResetFont()
    > ActiveCell.Font.Size = 10
    > End sub
    >
    >
    > ALSO IF I TRY
    > Sub ResetFont()
    > ActiveCell.Value = "1"
    > End sub
    >
    > *It throws an error in the cell with the =IF(...?*
    >
    >
    > --
    > Willot
    > ------------------------------------------------------------------------
    > Willot's Profile:
    > http://www.excelforum.com/member.php...o&userid=35166
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=549742
    >




  3. #3
    Registered User
    Join Date
    06-07-2006
    Posts
    3
    Yep. I see that. I just dont understand why it has a problem with the fact I want to change a properity of the cell.
    Is Excel just having one of it's turns?

  4. #4
    Chip Pearson
    Guest

    Re: Is Excel is now going out of it's way to mess me around?

    Functions called from a worksheet cell cannot change any other
    cell. This restriction is so that Excel can maintain its table of
    precedent and dependent cells. If VBA functions called from a
    worksheet cell were allowed to change cell values, Excel would
    have no idea how to calculate the sheet while preserving a valid
    table of precedents and dependents. It wouldn't have any idea
    what cells the VBA code might change.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Willot" <Willot.29246o_1149725403.148@excelforum-nospam.com>
    wrote in message
    news:Willot.29246o_1149725403.148@excelforum-nospam.com...
    >
    > Yep. I see that. I just dont understand why it has a problem
    > with the
    > fact I want to change a properity of the cell.
    > Is Excel just having one of it's turns?
    >
    >
    > --
    > Willot
    > ------------------------------------------------------------------------
    > Willot's Profile:
    > http://www.excelforum.com/member.php...o&userid=35166
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=549742
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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