+ Reply to Thread
Results 1 to 7 of 7

Using a macro to find matching numbers within tables

  1. #1
    Forum Contributor
    Join Date
    10-05-2016
    Location
    orange, ca
    MS-Off Ver
    0365 2209
    Posts
    144

    Using a macro to find matching numbers within tables

    Hello all hope every is doing well.

    I was wondering if there is a way to create a macro (or formula?) to highlight numbers in tables above it that match the numbers within the specified column and table.

    In the sample, in the the table at the bottom (Labeled TABLE in red), I highlighted the numbers in the column heading labeled t11 in red and highlighted in red the numbers that match those numbers in the 3 tables above it (hopefully I didn't miss any).

    Is there a macro that would highlight these numbers automatically in the above 3 tables.

    Note: the macro would have to be flexible because sometimes I may want to match the numbers in any other column like those in column heading t13 (highlighted blue to differ it from the previous numbers) or any other column in the table.

    A second sample (stock comparison 2) has been added to show the tables in different positions and matching a different header (t15)
    Attached Files Attached Files
    Last edited by lar9149; 03-29-2024 at 08:06 PM.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: Using a macro to find matching numbers within tables

    Below not very effective macro, but in small areas perhaps enough.
    Please Login or Register  to view this content.
    Artik

  3. #3
    Forum Contributor
    Join Date
    10-05-2016
    Location
    orange, ca
    MS-Off Ver
    0365 2209
    Posts
    144

    Re: Using a macro to find matching numbers within tables

    Quote Originally Posted by Artik View Post
    Below not very effective macro, but in small areas perhaps enough.
    Please Login or Register  to view this content.
    Artik
    Is there a way to make it adaptable..for example, I included a sample 2 (stock comparison 2 in original post) where the tables are moved down (no longer between B7-B37) and using the header on the bottom table of t15 at the end (P44).

    Is there a way to make the macro use the current selection (selected header) and match to the 3 tables above it as in the samples

    Note: the tables will always be in the same relative position in reference to each other.
    Last edited by lar9149; 03-28-2024 at 08:02 PM.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: Using a macro to find matching numbers within tables

    Assumptions for the operation of the following macro:
    1. between the last and penultimate table there is an empty row (in the example "Stock comparison 2", row 43 is empty).
    2. between the first three tables, the rows are not empty (cells C22 and C32 contain the value "lm" and there are formulas in rows 23 and 33)

    Color the fonts in the selected column in the last table and select the cell with the header. Run the macro.
    Please Login or Register  to view this content.
    The task can, of course, be solved in 100 other ways, analyzing the location and content of the tables in more detail. For now, this is one of the simplest solutions.

    Artik

  5. #5
    Forum Contributor
    Join Date
    10-05-2016
    Location
    orange, ca
    MS-Off Ver
    0365 2209
    Posts
    144

    Re: Using a macro to find matching numbers within tables

    Quote Originally Posted by Artik View Post
    Assumptions for the operation of the following macro:
    1. between the last and penultimate table there is an empty row (in the example "Stock comparison 2", row 43 is empty).
    2. between the first three tables, the rows are not empty (cells C22 and C32 contain the value "lm" and there are formulas in rows 23 and 33)

    Color the fonts in the selected column in the last table and select the cell with the header. Run the macro.
    Please Login or Register  to view this content.
    The task can, of course, be solved in 100 other ways, analyzing the location and content of the tables in more detail. For now, this is one of the simplest solutions.

    Artik
    This works beautifully and exactly the way I wanted.

    Thank you Artik

    If I added 2 tables under the same table as in sample 3 (stock comparison 3) , could this macro be adjusted so that it would compare the 3 tables above it and also 2 tables below doing the same thing. Also it didn't seem to bold the the colors?..can the macro bold the colors too?
    And again the relative positions of the tables stay the same
    Last edited by lar9149; 03-29-2024 at 10:02 AM.

  6. #6
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: Using a macro to find matching numbers within tables

    Follow the same steps as in version #2 before running the macro.
    Please Login or Register  to view this content.
    Use this macro to remove formatting from the target tables (also select a cell in the source table header)
    Please Login or Register  to view this content.
    Artik

  7. #7
    Forum Contributor
    Join Date
    10-05-2016
    Location
    orange, ca
    MS-Off Ver
    0365 2209
    Posts
    144

    Re: Using a macro to find matching numbers within tables

    Quote Originally Posted by Artik View Post
    Follow the same steps as in version #2 before running the macro.
    Please Login or Register  to view this content.
    Use this macro to remove formatting from the target tables (also select a cell in the source table header)
    Please Login or Register  to view this content.
    Artik
    Perfect your help is much appreciated. Will mark trend is solved.

+ 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: 7
    Last Post: 07-27-2022, 01:26 AM
  2. [SOLVED] Find matching dates with numbers and result these .
    By I need excel help in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-07-2022, 08:46 AM
  3. [SOLVED] Macro to run after matching column dates from two separate excel tables
    By Dbroek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-29-2020, 01:05 PM
  4. [SOLVED] Find all matching values in two tables and return identifier
    By Nora Kro in forum Excel General
    Replies: 3
    Last Post: 08-17-2018, 10:48 AM
  5. [SOLVED] Find matching header between two tables and returning that column's specific row value.
    By DaniLucas in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-14-2016, 11:03 AM
  6. Find Non Matching Value in rows between two tables
    By Keelin in forum Excel General
    Replies: 2
    Last Post: 02-17-2015, 12:20 AM
  7. [SOLVED] Find matching words in 10 columns and add row numbers of matching words
    By zeke 29 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-03-2012, 09:57 AM

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