+ Reply to Thread
Results 1 to 4 of 4

Macro calling up UDFs unexplainably

  1. #1
    Registered User
    Join Date
    07-27-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    1

    Macro calling up UDFs unexplainably

    Hi there,

    I'm running a Macro that fills in a UDF formula:

    ' CPC
    Worksheets("Report by Day").Range("F7").Value = "=IFERROR(CPCDATE('Report Config'!$B$4,'Report Config'!$D$4,E7,H7,Data!F:F,C7,Data!BK:BK),0)"

    Worksheets("Report by Day").Range("F" & LastRow & "").Value = "=IFERROR(J" & LastRow & "/E" & LastRow & ",0)"

    My procedure code works fine when I run it with my UDFs commented out but when I run it without the comment block. It jumps from my procedure to the UDF and then just loops through that continuosly.

    Is there any way to get around this?

  2. #2
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: Macro calling up UDFs unexplainably

    I think 2nd line should be something like this

    Worksheets("Report by Day").Range("F" & Lastrow & ":F" & Lastrow + 10).Value = "=IFERROR(J" & LastRow & "/E" & LastRow & ",0)"

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro calling up UDFs unexplainably

    Your function has to be calculated as you add it to each cell, so it's logical that control will jump there. Why is it an issue?
    Remember what the dormouse said
    Feed your head

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Macro calling up UDFs unexplainably

    Also, you should use Range.Formula (or Range.FormulaR1C1), not Range.Value, to assign a formula to a cell.
    Hope that helps,

    Colin

    RAD Excel Blog

+ 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