Results 1 to 3 of 3

Use of Variable Sheet Name in VBA Formula - Update Reference

Threaded View

R_S_6 Use of Variable Sheet Name in... 08-09-2010, 06:51 AM
romperstomper Re: Use of Variable Sheet... 08-09-2010, 07:18 AM
R_S_6 Re: Use of Variable Sheet... 08-10-2010, 03:20 AM
  1. #1
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Question Use of Variable Sheet Name in VBA Formula - Update Reference

    Hi All,

    Below are certain extracts of my code:

    
    Dim SheetName As String
    SheetName = CBO1_Engine.Value
    MsgBox SheetName
    
    
    Range("A1").Select
    ActiveCell.FormulaR1C1 = _
     "=CONCATENATE(""*testing "",""""""""," & SheetName & "!R[" & xStart & "]C[1],""_""," & SheetName & "!R[" & xStart & "]C[2],""_M=""," & SheetName & "!R[" & xStart & "]C[4],""kg"","""""""","" "","""""""""""","" ""," & SheetName & "!R[183]C[71],)"
    The above Code refers to a Concatenate formula I am running in a macro. It refers to two variables, the first being the worksheet 'SheetName' and the second being the Row reference 'xStart'. 'SheetName' is derived from the value of a user selection in a combobox.

    It runs however it comes up with an 'update reference' dialog box for the reference for the sheet. If I click cancel it leaves #NAME in the A1 Cell. If I look at the formula that the VBA has input into this cell it is correct apart from the apostrophes that surround the sheet, SheetName. Thus it thinks its just text. If I manually put these apostrophies in the formula works fine. Can someone advise as to how to modify the above to get it to work?

    Thanks in Advance
    Mark
    Last edited by R_S_6; 08-10-2010 at 02:08 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