Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Trying to use a macro to find the last NUMERIC cell after a range has been
sorted. ie: using the following in a macro---- Range(Range("l25"), Range("l25").End(xlDown)).Select column l: 1 5 8 6 1 I want to find this cell blank cell blank cell blank and so on TOS TOS TOS Tos The above macro finds this cell. Any help appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Your data as presented is not sorted... "1" appears in two non-adjacent cells and the blank cells are not at the bottom. The following works, but only in a single sorted column... Dim rng As Range Set rng = Selection.SpecialCells(xlCellTypeConstants, xlNumbers) Set rng = rng(rng.Count) MsgBox rng.Address Another way would be to loop from the bottom up looking for any number. -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) "shawnews" wrote in message Trying to use a macro to find the last NUMERIC cell after a range has been sorted. ie: using the following in a macro---- Range(Range("l25"), Range("l25").End(xlDown)).Select column l: 1 5 8 6 1 I want to find this cell blank cell blank cell blank and so on TOS TOS TOS Tos The above macro finds this cell. Any help appreciated. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm confused about what you're selecting, but if your numbers are values (not
formulas), you can use something like: Option Explicit Sub testme() Dim wks As Worksheet Dim LastNumericCell As Range Dim JustNumberConstants As Range Set wks = ActiveSheet Set JustNumberConstants = Nothing On Error Resume Next Set JustNumberConstants _ = wks.Range("a:a").Cells.SpecialCells(xlCellTypeCons tants, xlNumbers) On Error GoTo 0 If JustNumberConstants Is Nothing Then MsgBox "No number constants" Else With JustNumberConstants With .Areas(.Areas.Count) Set LastNumericCell = .Cells(.Cells.Count) End With End With MsgBox LastNumericCell.Address & vbLf & LastNumericCell.Value End If End Sub If your numbers are all the results of formulas, you could use: Set JustNumberConstants _ = wks.Range("a:a").Cells.SpecialCells(xlCellTypeForm ulas, xlNumbers) It gets a bit uglier if you have a mixture. shawnews wrote: Trying to use a macro to find the last NUMERIC cell after a range has been sorted. ie: using the following in a macro---- Range(Range("l25"), Range("l25").End(xlDown)).Select column l: 1 5 8 6 1 I want to find this cell blank cell blank cell blank and so on TOS TOS TOS Tos The above macro finds this cell. Any help appreciated. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
TO DELETE ONLY NUMERIC VALUES IN A CHARACTER AND NUMERIC CELL IN | Excel Discussion (Misc queries) | |||
How do I copy numeric section of cell from alpha-numeric cell | Excel Worksheet Functions | |||
How to populate a cell with numeric value based on textselected from pull down in adjacent cell? | Excel Worksheet Functions | |||
only extract numeric value from alpha numeric cell | Excel Discussion (Misc queries) | |||
Numeric in Text to convert back to the form of Numeric for VLookup Purposes | Excel Discussion (Misc queries) |