+ Reply to Thread
Results 1 to 6 of 6

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

Hybrid View

  1. #1
    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:
    Sub FindMax()
      'MAX is an Excel KEYWORD.  It is NOT RECOMMENDED to use Excel KEYWORDS as variables or function/Sub names.
    
      Dim r As Range
      Dim rw5 As Long
    
      For rw5 = 17 To 46
      
        Set r = Cells(rw5, 11)
    
        If r.Value - Cells(7, 6) <= 20 And r.Value - Cells(7, 6) > 0 Then
          r.Interior.ColorIndex = 6
          r.Font.Color = vbBlack
          r.Font.Bold = True
        End If
    
      Next rw5
    
      'Clear object pointer
      Set r = Nothing
    
    End Sub
    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:
    If a = b then
      c = d
    Endif
    Lewis
    Last edited by LJMetzger; 01-30-2015 at 12:55 PM.

  2. #2
    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

  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

    Thanks for the advise to !

    -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

    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:
    If a = b then
      c = d
    Endif
    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
    Range(r.value, Range("k65536").End(xlUp))
    Giving me errors.

    Any idea on that ?

+ 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