I'm brand new to VBA and using excel 2013. I've been racking my brain all day with this error! The lines marked with asteriks are getting
"Application-defined or object-defined error"
My function is supposed to do 2 things...
1) give the current cell a value
2) change the fill color of another cell
There are no issues with #1, but #2 keeps erroring out
This is the code that I'm currently using...
I'm calling it from within the cell in excel, giving it the formula: =ScoreIt()
Function ScoreIt()
Dim TotalVal As Integer, LRVal As Integer, LYVal As Integer, LGVal As Integer
TotalVal = 0
LRVal = 0
LYVal = 1
LGVal = 2
Dim CurrentRow As String, BedCell As String, Beds As Integer
CurrentRow = ActiveCell.Row
BedCell = Range("K" & CurrentRow).Address(False, False)
Beds = Range(BedCell).Value
If (Beds < 2) Or (Beds > 5) Then
TotalVal = TotalVal + LRVal
** Range(BedCell).Interior.ColorIndex = 38 **
ElseIf (Beds = 2) Or (Beds = 5) Then
TotalVal = TotalVal + LYVal
** Range(BedCell).Interior.ColorIndex = 36 **
ElseIf (Beds = 3) Or (Beds = 4) Then
TotalVal = TotalVal + LGVal
** Range(BedCell).Interior.ColorIndex = 35 **
End If
ScoreIt = TotalVal
End Function
Thank you
BedCellaRangeobject and just callset BedCell = Range("K" & CurrentRow)then just useBedCell.Interior.ColorIndex = 38