Selecting The Last Cell containing specific text doesn't work

CaptainCsaba

Board Regular
Joined
Dec 8, 2017
Messages
78
Hi!

I am trying to select the last cell in column A that contains numbers with the thousand separators eg 1,234,567. Previously in one of my other codes I used "*#,#*" but here it does not seem to work. If I write anything instead it perfectly finds it but not like this. What am I missing?

Code:
Sub SelectLastCell()Dim lr, i, n As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For i = lr To 2 Step -1
    On Error Resume Next
    n = WorksheetFunction.Search("*#,#*", Cells(i, 1))
    If Err = 0 Then
        Cells(i, 1).Select
        Exit For
    End If
Next i
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Perhaps :
Code:
Sub SelectLastCell()
Dim lr as Long, i as Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
    If Cells(i, 1) >= 1000 Then
        Cells(i, 1).Select
        Exit For
    End If
Next i
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,178
Messages
6,129,325
Members
449,501
Latest member
Amriddin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top