Results 1 to 4 of 4

Thread: Excel 2007 Macro Help (Buttons)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    2

    Excel 2007 Macro Help (Buttons)

    Hi I was wondering if someone could help me.

    I am creating a fairly simple excel data sheet to help out in work. I'll explain what I am trying to get it to do, then you might get the idea of where I am going wrong and hopefully point me in the right direction.

    I deal will a lot of return parts from one manufacturer and at present we have to look up each part number of there on line site to see what it is.

    So I have set up a spreadsheet with the first column containing the common search parameter replicated in each cell:

    Example: http://h20141.www2.hp.com/hpparts/Se...earchCriteria=

    And the next column has the barcode part numbers scanned in

    Example: A9739-69008

    In the following Colum I placed the formula =HYPERLINK(A1&""&B1) then copied and pasted in all the cells in the column.

    The combined result gives me a hyperlink to that parts information:
    http://h20141.www2.hp.com/hpparts/Se...ia=A9739-69008


    Now although this works great as a hyperlink to each part description, it looks untidy.

    What I want to do is create a button that can be pressed on each row than can do the same thing withoutlooking so untidy.

    I tried to create a macro for a button on the first row with the following code:

    Sub HP_link_2()
    ActiveWorkbook.FollowHyperlink Address:= Range("C1"),
    NewWindow:=True
    End Sub

    But it’s nowhere near right.

    Can someone help please?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Excel 2007 Macro Help (Buttons)

    you could add a button, which would open the parts site with the search criteria being the activecell value:

    vb Code:
    1. Private Sub CommandButton1_Click()
    2.     Dim partsSiteURL As String
    3.     partsSiteURL = "http://h20141.www2.hp.com/hpparts/SearchCriteria="
    4.     ActiveWorkbook.FollowHyperlink Address:=partsSiteURL & ActiveCell.Value
    5. End Sub

    then you'd just need a column with the barcode part numbers.
    Last edited by .paul.; Jan 28th, 2009 at 01:33 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    2

    Re: Excel 2007 Macro Help (Buttons)

    Thanks for your reply.

    Sorry for being completely stupid and no doubt you will laugh at this question.

    If the active cell is for example D1, what whould the exact code look like that I would have to put in to the button macro.

    I have tried a few variations with no luck

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Excel 2007 Macro Help (Buttons)

    you'd use the code i posted in post #2.

    to run it you'd select cell D1 for example, then click the button...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width