+ Reply to Thread
Results 1 to 7 of 7

Select column A's cell in relation to the row that macro button was clicked on?

  1. #1
    Forum Contributor
    Join Date
    03-21-2013
    Location
    USA
    MS-Off Ver
    365
    Posts
    163

    Select column A's cell in relation to the row that macro button was clicked on?

    Currently, I have a button on a spreadsheet that when pressed, runs a macro that grabs a template file and copies it to another location and renames it based on the value that is located, in this case, cell A3. What I'm trying to do is figure out how to change the specific cell location (A3), with some sort of variable that instead allows the code to always select column A's cell with relation to which row the button is located in.

    This form is going to have around 100-200 buttons all doing the same thing for each row that they are associated with. I'm just trying to avoid writing 200 different macro's for each one.

    Hopefully this is an easy one. I appreciate any help that any of you can give.


    sPath = ThisWorkbook.Path & "\" & Sheets(ActiveSheet.Name).Range("A3").Value

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Select column A's cell in relation to the row that macro button was clicked on?

    How about this

    Please Login or Register  to view this content.
    When you select column A it lifts the file name from the selected cell and runs the macro
    Elegant Simplicity............. Not Always

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Select column A's cell in relation to the row that macro button was clicked on?

    How did you create the buttons?

    If it's a Forms button you could use something like this.
    Please Login or Register  to view this content.
    Mind you having hundreds of buttons might not be a good idea.
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    03-21-2013
    Location
    USA
    MS-Off Ver
    365
    Posts
    163

    Re: Select column A's cell in relation to the row that macro button was clicked on?

    Quote Originally Posted by Norie View Post
    How did you create the buttons?

    If it's a Forms button you could use something like this.
    Please Login or Register  to view this content.
    Mind you having hundreds of buttons might not be a good idea.
    Here is the whole button. And yes, it is a forms button.

    Please Login or Register  to view this content.
    Edit Post... I guess I'm just not sure how to incorporate what you suggested into what I've written so far. :/

    Thank you for taking your time to help me out.
    Last edited by xlyfe; 04-09-2013 at 12:02 PM.

  5. #5
    Forum Contributor
    Join Date
    03-21-2013
    Location
    USA
    MS-Off Ver
    365
    Posts
    163

    Re: Select column A's cell in relation to the row that macro button was clicked on?

    Quote Originally Posted by AndyLitch View Post
    How about this

    Please Login or Register  to view this content.
    When you select column A it lifts the file name from the selected cell and runs the macro
    I'm not actually ever selecting the row, but instead, clicking on a forms button that is placed almost perfectly within the the very last cell of the row that I'm going to be having it create a new sheet and pull data from.

    I'm not even sure if what I'm trying to do is possible. This spreadsheet is kind of evolving as it's being created, thanks to the bosses continuous "what if's" after each updated revision.

    I appreciate all of your guy's help on this. I really do.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Try this, which you should assign to each button.

    Please Login or Register  to view this content.
    Last edited by Norie; 04-09-2013 at 12:06 PM.

  7. #7
    Forum Contributor
    Join Date
    03-21-2013
    Location
    USA
    MS-Off Ver
    365
    Posts
    163

    Re: Select column A's cell in relation to the row that macro button was clicked on?

    Quote Originally Posted by Norie View Post
    Try this, which you should assign to each button.

    Please Login or Register  to view this content.

    This is working like a charm Norie. Thank you soooo much for helping me out with this. What I thought was going to be some difficult task, you made seem extremely easy. I envy, and welcome, your genius. Thanks again!

+ 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