+ Reply to Thread
Results 1 to 8 of 8

How to USE """"" cells count """"" change font color

Hybrid View

  1. #1
    Registered User
    Join Date
    09-26-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    33

    How to USE """"" cells count """"" change font color

    Sub testtest()
    Dim hh As Integer
    For hh = Range("A1:D6").Cells.Count To 1 Step -1    '''''' 24 to 1
    If Cells(hh) < 1 Then
    Range("A1:D6").Cells(hh).Font.Color = vbRed '''''' cells.value <1 change font color red (and blank cells no change)
    Else
    Range("A1:D6").Cells(hh).Font.Color = vbBlue ''''' cells.value >1 change font color blue (and blank cells no change)
    End If
    Next
    End Sub
    this code not work, please help ! for reference attached image ra1AhNO.jpg
    Last edited by austin123456; 10-08-2013 at 06:26 PM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to USE """"" cells count """"" change font color

    Maybe:

    Sub austin123456()
    Dim rcell As Range
    For Each rcell In Range("A1:D6")
        If rcell.Value < 1 Then rcell.Font.ColorIndex = 3
        If rcell.Value > 1 Then rcell.Font.ColorIndex = 5
    Next rcell
    End Sub

  3. #3
    Registered User
    Join Date
    09-26-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: How to USE """"" cells count """"" change font color

    Quote Originally Posted by JOHN H. DAVIS View Post
    Maybe:

    Sub austin123456()
    Dim rcell As Range
    For Each rcell In Range("A1:D6")
        If rcell.Value < 1 Then rcell.Font.ColorIndex = 3
        If rcell.Value > 1 Then rcell.Font.ColorIndex = 5
    Next rcell
    End Sub
    Sub testtest()
    
    Set sht1 = Sheets("sheet1")
    Set sht2 = Sheets("sheet2")
    
    Dim rcell As Range
    Dim r2cell As Range
    
    For Each r2cell In sht2.Range("A1:D6")
    For Each rcell In sht1.Range("A1:D6")
    
    If sht1.rcell.Value - sht2.r2cell.Value < 1 Then
    sht1.rcell.Font.ColorIndex = 3
    End If
    
    Next
    Next
    
    End Sub
    Hello John,
    Thanks for yr response
    how to change this code ?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to USE """"" cells count """"" change font color

    I maybe be missing something regarding what you're trying to achieve. Can you attach a sample file with some data explaining before and after results? To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  5. #5
    Registered User
    Join Date
    09-26-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: How to USE """"" cells count """"" change font color

    Quote Originally Posted by JOHN H. DAVIS View Post
    I maybe be missing something regarding what you're trying to achieve. Can you attach a sample file with some data explaining before and after results? To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.
    attached file for yr ref.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to USE """"" cells count """"" change font color

    Maybe:

    Sub austin123456()
    Dim i As Integer
    Dim x As Integer
    For x = 1 To 6
    For i = 1 To 6
    If Sheets("Sheet1").Cells(i, x).Value - Sheets("Sheet2").Cells(i, x).Value < 1 Then
        Sheets("Sheet1").Cells(i, x).Font.ColorIndex = 3
    End If
    If Sheets("Sheet1").Cells(i, x).Value - Sheets("Sheet2").Cells(i, x).Value > 1 Then
        Sheets("Sheet1").Cells(i, x).Font.ColorIndex = 5
    End If
    Next i
    Next x
    End Sub
    Last edited by JOHN H. DAVIS; 10-08-2013 at 01:51 PM.

+ 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] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  3. Replies: 5
    Last Post: 10-12-2010, 06:46 AM
  4. Replies: 5
    Last Post: 06-26-2006, 09:23 PM
  5. Replies: 7
    Last Post: 05-13-2006, 05:02 PM

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