+ Reply to Thread
Results 1 to 2 of 2

VBA Code that references another cell in the same row as a command button

  1. #1
    Forum Contributor
    Join Date
    02-09-2011
    Location
    Perth, Australia
    MS-Off Ver
    2016
    Posts
    161

    VBA Code that references another cell in the same row as a command button

    Hi Forum,

    I have a worksheet called “Parts” that has information for each unique part, including the unique “Part Numbers” down column A.

    On another sheet, “Part Details”, I can enter a part number into cell A5 and details for that part are displayed (using VLookups).

    What I would like is to have a button, in column E, for each row in the Parts sheet. When the button is selected the Part Number associated with that row would appear in cell A5 of the Part Details sheet.

    What VBA code would I need for the button? I have tried recording a macro of copying and pasting the Part Numbers into cell A5 to see what that code looks like but I have been unable to modify that code to do what I want.

    Thanks very much

    Dave

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA Code that references another cell in the same row as a command button

    Hi there,

    See if the following code does what you need. It might appear "wordy" but I've deliberately implemented it in a few separate steps so that you can see what's involved.

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M



    P. S.

    Please Login or Register  to view this content.
    will certainly work, but it's a little less easy on the eye, and also on the grey cells when you're reading it six months from now!
    Last edited by Greg M; 05-31-2021 at 07:57 AM. Reason: P.S added

+ 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. [SOLVED] Copying ActiveX Command Button from master sheet to subsheets. command button code missing
    By popper08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2020, 10:15 AM
  2. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  3. [SOLVED] Changing the cell that a formula references using command button
    By Sinnie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2013, 09:35 AM
  4. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  5. Excel VBA Code for Command Button to Solve based on Cell Values
    By Ancientfall in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2012, 08:33 PM
  6. Command button code that fills two combo box values and a toggle in cell
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-03-2010, 12:03 AM
  7. Command Button with relative references ???
    By marcusjb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-10-2005, 01:11 PM

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