Makarand Chaudhari
Makarand Chaudhari

Reputation: 11

Excel Comparision to find the range of number

Hello Please consider my silly question, I am stuck here since a long time

ElseIf Cells(m1, a) >= 1 And Cells(m1, a) <= 98 Then

Cells(m1, a).Font.Bold = True

here only the values without decimal point (eg. 4,56,90)etc are getting bold, values with decimal point (4.5,56.5,90.54) despite being in the rqnge are not getting filtered.

Please suggest possible problem

I think the problem is with French numbering system as the data coming is from France.

Thank you

Is there any way to consider different numbering system, with the US system....???

Upvotes: 0

Views: 60

Answers (2)

Siddharth Rout
Siddharth Rout

Reputation: 149315

Try this

ElseIf Val(Cells(m1, a).Value) >= 1 And Val(Cells(m1, a).Value) <= 98 Then

If you are not running this code from the sheet code area then do not forget to fully qualify the cells object. For example

ThisWorkbook.Sheets("Sheet1").Cells(m1, a).Value

Upvotes: 1

enhzflep
enhzflep

Reputation: 13099

You should use Cells(m1,a).value as well as Cells(m1,a).value

The code below will examine the list of cell are selected before the macro is run. For each cell, if it's value is [1..98] then I take the state and toggle it.

Sub toggleBoldInSelection()
    Dim cellValue
    For Each curCell In Selection
        cellValue = curCell.Value
        If (cellValue >= 1) And (cellValue <= 98) Then
            curCell.Font.Bold = Not curCell.Font.Bold 'True
        End If
    Next curCell
End Sub

Upvotes: 1

Related Questions