Results 1 to 4 of 4

Setting Range.Formula with custom function

Threaded View

  1. #1
    Forum Contributor beeawwb's Avatar
    Join Date
    01-04-2004
    Location
    Perth, WA, Australia
    MS-Off Ver
    Microsoft Office Excel 2003 (11.8146.8221) SP2
    Posts
    105

    Setting Range.Formula with custom function

    Hi all,

    I recently set up some functions based on Chip Pearson's tutorial for referencing worksheets from Formulas. (http://www.cpearson.com/excel/sheetref.htm)

    The problem I'm now having is that I can't use VBA to set these functions in place; it returns a syntax error.

    For example, I want I37 on most sheets to have the same formula. So I have the following:

    For Each Worksheet In Worksheets
    
    Select Case Worksheet.Index
    
    Case 1, 2, 3
    'Do Nothing
    
    Case Else
    'The below returns a syntax error (highlighted in red)
    Worksheets(Worksheet.Index).Range("I37").Formula = "=RefOnPrevSheet("I39"))"
    
    End Select
    
    Next Worksheet
    When I type the formula directly in the cell, and debug.print it, it shows exactly what I've put in quotes. How can I put this formula into my cells without returning a syntax error?

    Cheers,

    Bob
    Last edited by beeawwb; 05-18-2009 at 11:56 PM.

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