+ Reply to Thread
Results 1 to 7 of 7

Replacing a value with a cell name

  1. #1
    Registered User
    Join Date
    06-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Replacing a value with a cell name

    What i want to do is:

    I want to be able to replace the bolded and underlined areas of this javascript i have pasted in a cell with the value located in another cell. This means that those numbers would be replaced by a similar thing located in another cell. how can this be done? The way I would think you would do this by defining that say =b8 (an example of where the data could be coming from is ann excel formula, but not sure how to do this

    javascript:function%20end(){c='578|717';var%20d=document;if(window.frames.length>0)d=window.main.document;url=d.URL;if(url.indexOf('screen=place')==-1)alert('This%20script%20needs%20to%20be%20run%20from%20the%20rally%20point');a=c.match(/(\d+\|\d+)/g);b=a[Math.round(Math.random()*(a.length-1))].split("|");d.forms[0].x.value=b[0];d.forms[0].y.value=b[1];d.forms[0].spear.value=0;d.forms[0].sword.value=0;d.forms[0].axe.value=0;d.forms[0].spy.value=0;d.forms[0].light.value=0;d.forms[0].heavy.value=0;d.forms[0].ram.value=1;d.forms[0].catapult.value=0;d.forms[0].snob.value=0;d.forms[0].archer.value=0;d.forms[0].marcher.value=0;d.forms[0].knight.value=0;}end();
    Last edited by dextras; 06-12-2009 at 07:48 PM.

  2. #2
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Replacing a value with a cell name

    Hehe...looks like we're editing a character/game file to give ourselves more health/gold...something like that, hehe?

    Anyway, if that text string is in A8, and the replacement text string is in B8, then this formula will substitute the two 3-digit strings and the separator with whatever string you have in B1:

    =LEFT(A8, 31) & B8 & RIGHT(A8, LEN(A8) - 38)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    06-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Replacing a value with a cell name

    Thank you so much. How do I get it to also alter the 0 later on in the code?

    It is for a game but it is legal.They allow certain scripts

  4. #4
    Registered User
    Join Date
    06-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Replacing a value with a cell name

    Nevermind. Got it figuered out. THanks so much. THanks heaps. +1

    EDIT: Just realised. How do I put them both in the same formula?

    My formulas:

    =LEFT(Info!A38, 31) & A6 & RIGHT(Info!A38, LEN(Info!A38) - 38)
    and
    =LEFT(Info!A38, 400) & U6 & RIGHT(Info!A38, LEN(Info!A38) - 400)
    Last edited by dextras; 06-12-2009 at 03:26 AM.

  5. #5
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Replacing a value with a cell name

    If you know the exact values, this would work, a little simpler, actually:

    =SUBSTITUTE(SUBSTITUTE(Info!A8, ".light.value=0", ".light.value=" & U6), "{c='578|717", "{c='" & A6)
    Last edited by JBeaucaire; 06-12-2009 at 04:26 AM.

  6. #6
    Registered User
    Join Date
    06-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Replacing a value with a cell name

    Thank you again, that works way better. ty +1 if i can

  7. #7
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Replacing a value with a cell name

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

+ 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