+ Reply to Thread
Results 1 to 3 of 3

Cell Reference Error use for conditional formatting

Hybrid View

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Cell Reference Error use for conditional formatting

    Hello,
    I am currently receiving an error while trying to reference a cell using an ActiveCell.Offset Command. I must not be using it correctly.
    I cannot reference the cell directly because it is not always in the same location. and resolution ideas?
    Here is the code:
    'Start new variants
    Dim BidLabTot As Variant
    Dim BidMatTot As Variant
    Dim BidSubTot As Variant
    Dim BidRenTot As Variant
    Dim BidOwnTot As Variant
    Dim BidTot As Variant
    
      ' Setting the variants to equal the correct values
        BidLabTot = ThisWorkbook.Sheets("CODESHEET UNSORTED").Range(ActiveCell.Offset(6, 0)).Value
        BidMatTot = ThisWorkbook.Sheets("CODESHEET UNSORTED").Range(ActiveCell.Offset(6, 1)).Value
        BidSubTot = ThisWorkbook.Sheets("CODESHEET UNSORTED").Range(ActiveCell.Offset(6, 2)).Value
        BidRenTot = ThisWorkbook.Sheets("CODESHEET UNSORTED").Range(ActiveCell.Offset(6, 3)).Value
        BidOwnTot = ThisWorkbook.Sheets("CODESHEET UNSORTED").Range(ActiveCell.Offset(6, 4)).Value
        BidTot = ThisWorkbook.Sheets("CODESHEET UNSORTED").Range(ActiveCell.Offest(6, 5)).Value
    Then I am also concerned I am not using the Variants correctly in the conditional formatting, however, I don't know this for sure because I haven't gotten this far yet.

    Here is the code showing how I am using the variants above to conditional format them (the goal is to turn the active cell green and bold (with white letters) when the cells values are within .5).
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
            Formula1:=BidLabTot - 0.5, Formula2:=BidLabTot + 0.5
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Font
            .Bold = True
            .Italic = False
            .ThemeColor = xlThemeColorDark1
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 5287936
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
    Thank you all.

  2. #2
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Cell Reference Error use for conditional formatting

    I'm not sure if the problem was unclear or not, This is the line in which the error occurs. Obviously the error would apply to each line that is near identical to this one:

       BidLabTot = ThisWorkbook.Sheets("CODESHEET UNSORTED").Range(ActiveCell.Offset(6, 0)).Value
    The error states: Run-time error '1004':
    Application-defined or object-defined error

    The error definition in VBA is Identifier under cursor is not recognized.

  3. #3
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Cell Reference Error use for conditional formatting

    I split this thread to contain only one question at a time.
    The thread located here addresses the variable issue: http://www.excelforum.com/excel-prog...of-a-cell.html
    This thread has been solved.

    The second question resolved itself when the first question was solved.
    Thanks to JOHN H. DAVIS: http://www.excelforum.com/members/john-h-davis.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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