+ Reply to Thread
Results 1 to 3 of 3

Macro Stops at .Formula Code

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro Plus 2021
    Posts
    424

    Macro Stops at .Formula Code

    Hi,

    This code

        With Range("AU2:AU" & Lr)
            .Formula = "=IF(AP2<>0,AP2,"")"
            .Font.Name = "Tahoma"
            .Font.Size = 10
            .NumberFormat = "0"
        End With
    Falls over at the
    .Formula = "=IF(AP2<>0,AP2,"")"
    part

    If I change it to
    .Formula = "=IF(AP2<>0,AP2,0)"
    it works, so it obviously has something to do with the double "". Trouble is I don't want a zero I want a blank cell.

    Thanks for any help.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro Stops at .Formula Code

    You need to enter double quotes twice - so it becomes:

    .Formula = "=IF(AP2<>0,AP2,"""")"
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro Plus 2021
    Posts
    424

    Re: Macro Stops at .Formula Code

    Thanks OllyXLS - Perfect!

+ 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. Excel Visual Basic Macro code stops working
    By LPChester in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2013, 07:56 AM
  2. Removing code line stops code working?!?!?
    By adamj1910 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2012, 02:36 PM
  3. code stops working when i put a formula in the cell
    By Sarangsood in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-20-2011, 12:00 PM
  4. Short code question, macro stops
    By ExcelStarter in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-26-2009, 05:48 PM
  5. macro stops on "selection.autofilter" line of code
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-10-2005, 10:55 AM

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