+ Reply to Thread
Results 1 to 10 of 10

How to use conditional highlighting on two different workbooks using a Macro/VBA

  1. #1
    Registered User
    Join Date
    06-05-2024
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    5

    How to use conditional highlighting on two different workbooks using a Macro/VBA

    I have two workbooks and I’m trying to go through them and highlight the following.

    In each row where an error is identified, I want to highlight the (“Errors”) column, the (“Employee”) column as well as the column with the specified error.
    I was able to hard code the "Errors" column as "A" but the "Employee" column varies between the two workbooks. In the first workbook its "H" and in the second one its "J"

    Is there anyway I can highlight properly based on header name regardless of where the column is in the sheets? Here's what I've tried so far.

    Any help would be greatly appreciated!

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2407
    Posts
    25,974

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    Welcome to the Forum related!

    The question you are asking is specific to the data you have and the way it is organized in your files. We could do a read-through analysis of your code, but we can't run it without your files, and we can't test any updates without your files.

    Please attach examples of the two different workbooks. I assume of them contains this code. (See yellow banner at the top of the page.)

    I am unclear as to the problem you are trying to solve. This code has no reference to cells in column J of the containing workbook. Where are you trying to highlight that column?
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    06-05-2024
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    5

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    Thanks for your reply!

    The problem I'm trying to solve is basically how can I highlight based on header names rather than column names. I want to highlight the column with header name of "Employee" regardless of where it exists in each workbook. I was previously changing it between H and J manually each time which is why the code has no reference to cells in column J.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,303

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    Possibly adapting this to your code...
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-05-2024
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    5

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    I'm getting an error 91 object variable not set for this line

    Please Login or Register  to view this content.
    Is there something I'm missing?

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,303

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    Possibly the last cell is separate from the data?

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2407
    Posts
    25,974

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    I suggest you attach your Excel file so we can test code updates with your data and layout. See yellow banner at the top of the page.

  8. #8
    Registered User
    Join Date
    06-05-2024
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    5

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    dangelor: I don't believe the last cell is separate from the data.

    6StringJazzer: I can make two sample workbooks that show my structure but my Macro is in a third workbook that I use in UiPath to run it on the workbooks. I don't know if that would help

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2407
    Posts
    25,974

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    No idea what UiPath is but the two workbooks should be sufficient. It looks like this code operates on one other workbook, and does not refer to itself. The problem with dangelor's code is probably that it refers to ThisWorkbook.

  10. #10
    Registered User
    Join Date
    06-05-2024
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    5

    Re: How to use conditional highlighting on two different workbooks using a Macro/VBA

    Okay, I will make two sample workbooks and get back to you guys. Thanks again for being open to help!

+ 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. VBA Comparing data between two workbooks and highlighting any changes
    By Disco2000! in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-14-2021, 05:11 AM
  2. Comparing data between two workbooks and highlighting any changes
    By Disco2000! in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-14-2021, 05:07 AM
  3. Replies: 6
    Last Post: 02-15-2018, 11:54 PM
  4. Replies: 2
    Last Post: 02-06-2013, 12:13 AM
  5. Replies: 0
    Last Post: 02-05-2013, 07:51 AM
  6. [SOLVED] Highlighting cells between two workbooks.
    By RMF in forum Excel General
    Replies: 0
    Last Post: 08-12-2006, 08:35 AM
  7. Comparing two workbooks and highlighting the differences
    By Charles C. in forum Excel General
    Replies: 2
    Last Post: 07-26-2006, 02:20 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