M
Martin Wheeler
xl2000
I am trying to introduce a variable into some existing code, below. I am
trying to get the value of F to change depending on the value of A. The
problem is with F, I think. When I simply set FT.value to 25 or 35 it runs
fine.
The code is running but not doing anything.
Any help would be appreciated.
Ta,
Martin
Public Sub FTwentyFive1()
Dim Ce As Range
Dim FT As Range
Dim D As Range
A = Application.WorksheetFunction.CountIf(Range("G8:I12"), "<-.05")
B = Application.WorksheetFunction.CountIf(Range("J8:J10"), "<-.04")
C = Application.WorksheetFunction.CountIf(Range("J11:J12"), "<-.05")
A = A + B + C
If A = 0 Then
F = 35
Else
F = 25
For Each FT In Range("K7:K31")
If FT.Value >= F Then
Set D = FT
With D.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlColorIndexAutomatic
End With
Set Ce = D.Offset(-1, 0)
With Ce.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlColorIndexAutomatic
End With
Exit For
End If
Next
End If
End Sub
I am trying to introduce a variable into some existing code, below. I am
trying to get the value of F to change depending on the value of A. The
problem is with F, I think. When I simply set FT.value to 25 or 35 it runs
fine.
The code is running but not doing anything.
Any help would be appreciated.
Ta,
Martin
Public Sub FTwentyFive1()
Dim Ce As Range
Dim FT As Range
Dim D As Range
A = Application.WorksheetFunction.CountIf(Range("G8:I12"), "<-.05")
B = Application.WorksheetFunction.CountIf(Range("J8:J10"), "<-.04")
C = Application.WorksheetFunction.CountIf(Range("J11:J12"), "<-.05")
A = A + B + C
If A = 0 Then
F = 35
Else
F = 25
For Each FT In Range("K7:K31")
If FT.Value >= F Then
Set D = FT
With D.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlColorIndexAutomatic
End With
Set Ce = D.Offset(-1, 0)
With Ce.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlColorIndexAutomatic
End With
Exit For
End If
Next
End If
End Sub