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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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