Results 1 to 6 of 6

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

Threaded View

subbby Code highlights additional... 01-30-2015, 11:22 AM
LJMetzger Re: Code highlights... 01-30-2015, 12:31 PM
subbby Re: Code highlights... 01-30-2015, 12:37 PM
subbby Re: Code highlights... 01-30-2015, 12:39 PM
subbby Re: Code highlights... 01-30-2015, 12:56 PM
LJMetzger Re: Code highlights... 01-30-2015, 02:42 PM
  1. #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:
    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.

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