+ Reply to Thread
Results 1 to 6 of 6

Code highlights additional activecell in addition to what it has to highlight

  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Code highlights additional activecell in addition to what it has to highlight

    I have this excel sheet where : (file attached
    • Values in row 11 are compared with a value in Cells(7,6)
    • The code has to identify a value in row 11 by
    • Cells(rw5, 11) - Cells(7, 6) <= 20 And Cells(rw5, 11) - Cells(7, 6) > 0
    • After it identifies its color index and its characters have to be changed

    My problem:
    • Code works fine but it also highlights any cell that was first selected.
    • Eg. when you open up this sheet and click on a cell anywhere (say Rang A1) and then run this program. The code in addition to what I want it to do, also highlights Range A1
    • I guess it has to do with Activcell.select thingy

    Code Used
    Please Login or Register  to view this content.
    Another concern..

    Doesn’t allow me to use END IF… is there a reason why it doesn’t allow me to use END IF in spite of having IF
    Attached Files Attached Files
    Last edited by subbby; 01-30-2015 at 11:24 AM. Reason: added excel sheet

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Code highlights additional activecell in addition to what it has to highlight

    Hi subby,

    Try the following tested and working code:
    Please Login or Register  to view this content.
    a. By eliminating 'Select', the other cell was not highlighted.
    b. When you had if ... then on the same line, Excel thought the if statement was completed.
    It takes a lot more space, but I almost always use the following if construction:
    Please Login or Register  to view this content.
    Lewis
    Last edited by LJMetzger; 01-30-2015 at 12:55 PM.

  3. #3
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Code highlights additional activecell in addition to what it has to highlight

    Thank you very much.. That worked....

    Thanks

    -Subbby

  4. #4
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Code highlights additional activecell in addition to what it has to highlight

    Thanks for the advise to !

    -Subbby

  5. #5
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Code highlights additional activecell in addition to what it has to highlight

    Quote Originally Posted by LJMetzger View Post
    Hi subby,



    a. By eliminating 'Select', the other cell was not highlighted.
    b. When you had if ... then on the same line, Excel thought the if statement was completed.
    It takes a log more space, but I almost always use the following if construction:
    Please Login or Register  to view this content.
    Lewis
    Just an add on requirement.

    I do have to change interior color index of ALL CELLS with a value in it under the r.value cell. I used
    Please Login or Register  to view this content.
    Giving me errors.

    Any idea on that ?

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Code highlights additional activecell in addition to what it has to highlight

    Hi,

    Your syntax is close, but just not quite right. You need Range(Range1,Range2), but You have Range(Value,Range2).

    Try:
    Please Login or Register  to view this content.
    It seems like you may want to exit the loop, when you find your match. To do this you can use:
    Please Login or Register  to view this content.
    Lewis

+ 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] Highlight activecell's row and column
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-27-2014, 02:22 PM
  2. Code that highlights a row
    By reignkystar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2013, 09:55 PM
  3. [SOLVED] Highlight Row of ActiveCell
    By kicker850 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2013, 05:24 PM
  4. [SOLVED] Highlight input cells but print without the highlights
    By plamb in forum Excel General
    Replies: 3
    Last Post: 09-07-2012, 12:48 PM
  5. highlight activecell
    By flow23 in forum Excel General
    Replies: 10
    Last Post: 02-21-2006, 08:10 AM

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