Results 1 to 6 of 6

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

Threaded View

  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
    Sub max()
    Dim rw5 As Long
    
    For rw5 = 17 To 46
    
    If Cells(rw5, 11) - Cells(7, 6) <= 20 And Cells(rw5, 11) - Cells(7, 6) > 0 Then Cells(rw5, 11).Select
    ActiveCell.Interior.ColorIndex = 6
    ActiveCell.Font.Color = vbBlack
    ActiveCell.Font.Bold = True
    'End If
    Next rw5
    
    End Sub
    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

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