Red over White
Board Regular
- Joined
- Jul 16, 2011
- Messages
- 129
- Office Version
- 365
- Platform
- MacOS
I have try to research the answer to the above issue and came across the following feed from 2015 - Find sheet that contains the highest number using VBA
The original poster the vba provided largely works.
Having input some of the code
Sub Macro()
Dim lngMyNumber As Long
Dim wsMysheet As Worksheet
Dim wsHighestSheet As Worksheet
For Each wsMysheet In ThisWorkbook.Sheets
If lngMyNumber = 0 Then
If RetNumerics(CStr(wsMysheet.Name)) > 0 Then
lngMyNumber = RetNumerics(CStr(wsMysheet.Name))
Set wsHighestSheet = wsMysheet
End If
Else
If Val(RetNumerics(CStr(wsMysheet.Name))) > lngMyNumber Then
lngMyNumber = RetNumerics(CStr(wsMysheet.Name))
Set wsHighestSheet = wsMysheet
End If
End If
Next wsMysheet
End Sub
However, I am getting "Compile error: Sub or Function not defined" on RetNumerics. Can anyone provide a solution and also say if I'm going to hit an issue with 'CStr' once past the initial hurdle.
Thanks
The original poster the vba provided largely works.
Having input some of the code
Sub Macro()
Dim lngMyNumber As Long
Dim wsMysheet As Worksheet
Dim wsHighestSheet As Worksheet
For Each wsMysheet In ThisWorkbook.Sheets
If lngMyNumber = 0 Then
If RetNumerics(CStr(wsMysheet.Name)) > 0 Then
lngMyNumber = RetNumerics(CStr(wsMysheet.Name))
Set wsHighestSheet = wsMysheet
End If
Else
If Val(RetNumerics(CStr(wsMysheet.Name))) > lngMyNumber Then
lngMyNumber = RetNumerics(CStr(wsMysheet.Name))
Set wsHighestSheet = wsMysheet
End If
End If
Next wsMysheet
End Sub
However, I am getting "Compile error: Sub or Function not defined" on RetNumerics. Can anyone provide a solution and also say if I'm going to hit an issue with 'CStr' once past the initial hurdle.
Thanks