+ Reply to Thread
Results 1 to 9 of 9

Use an input variable inside a formula

  1. #1
    Registered User
    Join Date
    05-05-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 365
    Posts
    26

    Use an input variable inside a formula

    Hi all,

    I am trying to create a code that would input a formula, that would split the text from a referenced cell, based on a variable ('Split'). The formula would be apply within the active cell and would prompt the user to select which cell they want to use as a reference ('sCell').

    I have come up with the following, however it the sCell variant doesn't seem to work as it inputs the text within the formula...

    Appreciate if anyone could assist.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: Use an input variable inside a formula

    Maybe try sCell.Address
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-05-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Use an input variable inside a formula

    Thanks Guru but where about in the code should i place this?

  4. #4
    Registered User
    Join Date
    05-05-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Use an input variable inside a formula

    For info, if I remove "Type:=8" then it brings up the cell i have selected, however puts it in between a ' around the reference. As an example if i select cell A1 when asked, the formula will return 'A1', making the formula an error.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: Use an input variable inside a formula

    sCell.Address instead of just sCell

  6. #6
    Registered User
    Join Date
    05-05-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Use an input variable inside a formula

    Hi TMS, it doesn't work...

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: Use an input variable inside a formula

    OK, try this:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-05-2016
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Use an input variable inside a formula

    Great, that worked. Thanks for your help TMS.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: Use an input variable inside a formula

    You're welcome.

+ 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. Use VBA to Input Formula with a Variable/Changing Range
    By excel6000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-10-2015, 05:14 AM
  2. [SOLVED] Change one number in a cell inside a formula to a variable that is getting higher (+1)
    By chablo309 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2015, 07:28 AM
  3. Replies: 6
    Last Post: 09-06-2012, 01:07 AM
  4. [SOLVED] external link reference formula inside formula user input
    By jscc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-20-2012, 04:29 PM
  5. Using a variable inside a worksheet reference in a formula
    By Guinness85 in forum Excel General
    Replies: 1
    Last Post: 07-25-2011, 06:44 PM
  6. Can you use a variable in VBA code inside an excel worksheet formula?
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-19-2010, 03:49 PM
  7. Concatenation of a variable inside a formula
    By ksmith99 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-14-2006, 04:14 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