+ Reply to Thread
Results 1 to 5 of 5

Identify Entire Row of a Table

  1. #1
    Registered User
    Join Date
    09-25-2008
    Location
    Winnetka, CA
    Posts
    83

    Identify Entire Row of a Table

    When the user selects any cell in Table1, I want to highlight the whole row of the table. (Please note that the table does not start on Row 1 of the spreadsheet.)

    I need to either select the entire row, or set it as a range, based on what cell is selected.

    How can i do this in VBA? Thanks.

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

    Re: Identify Entire Row of a Table

    You've asked several questions as if they were the same things, they are not. Please outline exactly the one thing you want to do....

    1) Set a range variable in vba based on the current select cell
    Please Login or Register  to view this content.

    2) Select/Highlight the current row that is selected
    Please Login or Register  to view this content.
    3) Copy the entire row of the currently selected cell
    Please Login or Register  to view this content.
    etc...
    _________________
    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
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Identify Entire Row of a Table

    Maybe something like this.....
    • Select the sheet that contains the table
    • Right-click on the tab name and select: View Code...to open the VBA editor for that sheet module
    • Copy the below VBA code and past it into that module:
    Please Login or Register  to view this content.
    When you return to your worksheet....Whenever you click on any cell within the table body
    ...All additional formats on the table are cleared
    ...The entire table row is highlighted yellow.

    Note: I used a table name of "Table1". Change that in the code to your table's name

    EDITED TO INCLUDE THIS ALTERNATIVE:
    If you meant you want to SELECT that table row...use this code instead:
    Please Login or Register  to view this content.
    Last edited by Ron Coderre; 06-30-2014 at 08:39 PM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    09-25-2008
    Location
    Winnetka, CA
    Posts
    83

    Re: Identify Entire Row of a Table

    Quote Originally Posted by JBeaucaire View Post
    You've asked several questions as if they were the same things, they are not. Please outline exactly the one thing you want to do....

    1) Set a range variable in vba based on the current select cell
    Please Login or Register  to view this content.

    2) Select/Highlight the current row that is selected
    Please Login or Register  to view this content.
    3) Copy the entire row of the currently selected cell
    Please Login or Register  to view this content.
    etc...

    I want to change the background color of a table row to yellow. (That's what I meant by "highlight"). The ".Interior" command has to follow a Range name or "Selection" or "Target".

    The code I originally tried was something like this:

    Please Login or Register  to view this content.


    The problem is that "EntireRow" selects the entire row of the worksheet. I only want to highlight the current row of the table that takes up Columns G through Q. (And I may move the table again, so I don't want to refer specifically to "G" and "Q".)


    EDIT: Ron, what I wanted was your second suggestion:

    Please Login or Register  to view this content.

    Thanks!
    Last edited by shawnvw; 06-30-2014 at 09:31 PM.

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Identify Entire Row of a Table

    Glad you got something you can use!

    Please be sure to mark this thread as SOLVED (from the Thread Tools menu)

+ 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. Replies: 3
    Last Post: 06-05-2014, 06:59 PM
  2. Replies: 0
    Last Post: 07-30-2013, 07:42 PM
  3. [SOLVED] Copying the entire row from TABLE A that meets certain criteria to another Table
    By jjin in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-17-2012, 08:56 PM
  4. Identify if string exists, copy entire row.
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-26-2011, 02:57 AM
  5. Replies: 3
    Last Post: 08-17-2011, 05:07 PM

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.6.0 RC 1