+ Reply to Thread
Results 1 to 9 of 9

Problem changing cell formula in VBA

  1. #1
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Problem changing cell formula in VBA

    Hi,
    I have assigned formulas to a table in excel side. I have a macro that should replace those formulas in said cells in case someone has changed them.
    The code here seems unnecessarily complex but basically what it should do is replace the formula of cell with the same exact formula it already has at the moment, with Cells().Formula

    There are 4 rows of these replaces and I had trouble with all of them at first. I noticed that I had to replace some semicolons ( with colons (,). By doing this, 3 out of 4 now seem to work.

    There's a problem still with the lowest row. I've tried all kinds of combinations of colon and semicolon but I can't get it to work.

    The whole code:

    Please Login or Register  to view this content.
    Simplified, all it really is:
    Please Login or Register  to view this content.
    Can someone help me with this?
    Thanks

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Problem changing cell formula in VBA

    It should read:

    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Problem changing cell formula in VBA

    I tried this, and i still get error 1004 (application-defined or object-defined error)

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Problem changing cell formula in VBA

    Just noticed your actual formula is wrong, as you have 4 argments to your IF function. What is the original cell formula?

  5. #5
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Problem changing cell formula in VBA

    The 7,5 is a decimal value. That's probably causing the problem but i don't know how to insert the value 7,5 there otherwise.

    This is the copied code from cell
    [CODE][/=[@Työtunnit]-(IF(WEEKDAY([@Pvm];2)>5;0;IF(ISERROR(MATCH([Pvm];Holidays[Pvm];0))=FALSE;0;7,5)))CODE]

  6. #6
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Problem changing cell formula in VBA

    Quote Originally Posted by Jupsu View Post
    The 7,5 is a decimal value. That's probably causing the problem but i don't know how to insert the value 7,5 there otherwise.

    This is the copied code from cell
    Please Login or Register  to view this content.
    fixed earlier message

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Problem changing cell formula in VBA

    Oh, then it's:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Problem changing cell formula in VBA

    Quote Originally Posted by rorya View Post
    Oh, then it's:

    Please Login or Register  to view this content.
    Ah, of course. Thank you very much, it works now!

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Problem changing cell formula in VBA

    Glad to help.

+ 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. Replies: 18
    Last Post: 02-20-2018, 04:27 PM
  2. [SOLVED] Problem with formula changing the cel number format
    By SL_Mills in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-07-2016, 02:19 PM
  3. Replies: 3
    Last Post: 07-16-2014, 10:44 AM
  4. [SOLVED] Copy a sheet with formulas - Problem - formula's are changing!
    By kaligad in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-25-2013, 07:18 AM
  5. [SOLVED] Problem Changing Cell Formating
    By SteveB in forum Excel General
    Replies: 0
    Last Post: 04-26-2006, 07:45 AM
  6. [SOLVED] Problem with formulas changing cell reference
    By janicesweet in forum Excel General
    Replies: 1
    Last Post: 08-02-2005, 02:05 PM
  7. Cell Format problem, not changing
    By davidbeecken in forum Excel General
    Replies: 1
    Last Post: 06-17-2005, 06:05 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