+ Reply to Thread
Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    01-17-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    How turn this excellent code into a macro

    =MATCH(A1,B1:B5,0)
    =ADDRESS(A2,2)
    =HYPERLINK("#"&A3,"this message text is not required in the macro")

    The above, when put into worksheet goes to cell where data matches.
    eg A1=eggs. In col b eggs is in cell B4, so clicking on hyperlink takes one to cell b4

    So how to make a macro out of this to copy data from any other cell into the matched
    cell, eg cell B4 if it is a match. Reference data, obviously, in cell A1 is variable.
    The hyperlink code above has a message area but that would not be necessary for a macro.

    If it is not possible doing it this way, suggestions please.
    Last edited by alfiebaby; 01-18-2010 at 12:02 AM.

  2. #2
    Forum Moderator pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,141

    Re: How turn this excellent code into a macro

    Hi alfiebaby
    can you run that past me again
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    JBeaucaires Excel Files

    VBA for smarties - snb

  3. #3
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,042

    Re: How turn this excellent code into a macro

    to add to pike's request:

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon below the post.

    Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.

  4. #4
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,228

    Re: How turn this excellent code into a macro

    Well, first, here's a ONE-CELL version of your three-cell process so you don't the values in A2 and A3...this formula does it all:

    =HYPERLINK("#"&ADDRESS(MATCH(A1,B1:B5,0), 2), "this message text is not required in the macro")

    Thanks for this! What a great little trick, I can think of several applications for this already.
    _________________
    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!)

  5. #5
    Registered User
    Join Date
    01-17-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How turn this excellent code into a macro

    cell a1="eggs on toast" Cell Z1="glue on toast"

    col b
    french
    bread
    with
    eggs on toast <that is overwritten by contents of cell Z1
    is nice
    to eat

    So previously shown match and address find the match in column B and then copies data
    from Z1 to cell where match was found.

  6. #6
    Registered User
    Join Date
    01-17-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How turn this excellent code into a macro

    cell a1="eggs on toast" Cell Z1="glue on toast"

    col b
    french
    bread
    with
    eggs on toast <that is overwritten by contents of cell Z1
    is nice
    to eat

    So previously shown match and address find the match in column B and then copies data
    from Z1 to cell where match was found.

  7. #7
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: How turn this excellent code into a macro

    Can you first of all explain your title? You have posted a formula not code, why do you need a macro?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  8. #8
    Registered User
    Join Date
    01-17-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How turn this excellent code into a macro

    Quote Originally Posted by royUK View Post
    Can you first of all explain your title? You have posted a formula not code, why do you need a macro?
    Okay, dunno the terminology as yet, only started writing a program a few months ago.
    need macro so that i can copy data from a set range to any location in the spread sheet
    after it has found where the data is.
    a1=eggs (the reference data)

    Find row eggs is in copy data from B1:Z1 starting at row and coll where eggs was found. eg (R20C4)

    the next search and replace (or update of data in the row) may be dogs and in completely different row and so on eg (R40,C2). The constant is B1:Z1 (as an example)

    The ability to do this with a macro opens up all sorts of time saving code writing possibilities.
    I think that many would find this extremely useful code/formula
    Last edited by alfiebaby; 01-22-2010 at 02:25 AM.

  9. #9
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: How turn this excellent code into a macro

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  10. #10
    Registered User
    Join Date
    01-17-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How turn this excellent code into a macro

    hyperlink.xlsm

    Have included file. Should I repost the whole thing again? Really would like to get
    a solution to this ASAP.

    Tanks in anticipation

  11. #11
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: How turn this excellent code into a macro

    Do not repost,but you haven't added a file. Check it is not too big for attaching. If it is remove unnecessary formatting and/or zip it
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  12. #12
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: How turn this excellent code into a macro

    Not sure if this is what you mean
    Attached Files Attached Files
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  13. #13
    Registered User
    Join Date
    01-17-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How turn this excellent code into a macro

    Hi Roy, looked at what I sent and scratched my head trying to figure out what I meant also!
    I will study the code u sent regardless, as it will give me an insight.

    However, I have simplified the problem and you should have no trouble this time understanding it.

    Thanks for your efforts.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0