Hello,
I have just migrated to Win 10 and been told I can no longer keep Excel 2000 on my Win 10 machine.
I have some old macros that were written by someone else back in 2002 that I would like to have running but no longer work.
I believe it has to do with the ribbon interface.
Can anyone provide some help on where to get started and if this will be a simple insert or hours worth of development?
Sub StatFunctions()
'Creates toolbar for quick stat functions
Dim statBar As CommandBar
Dim aBtn As CommandBarControl
'Create toobar
Set statBar = CommandBars.Add(Name:="Stats", _
Position:=4, _
MenuBar:=False, _
temporary:=False)
'Populate the toolbar
With statBar.Controls
'Create standard deviation button
Set aBtn = .Add(Type:=msoControlButton, temporary:=False)
aBtn.FaceId = 98
aBtn.OnAction = "Stdev"
aBtn.Caption = "Standard Deviation"
aBtn.Tag = True
'Create variance button
Set aBtn = .Add(Type:=msoControlButton, temporary:=False)
aBtn.FaceId = 101
aBtn.OnAction = "Var"
aBtn.Caption = "Variance"
aBtn.Tag = True
'Create Median Button
Set aBtn = .Add(Type:=msoControlButton, temporary:=False)
aBtn.FaceId = 92
aBtn.OnAction = "Median"
aBtn.Caption = "Median"
aBtn.Tag = True
'Create Standard Error Button
Set aBtn = .Add(Type:=msoControlButton, temporary:=False)
aBtn.FaceId = 84
aBtn.OnAction = "Std_Error"
aBtn.Caption = "Standard Error"
aBtn.Tag = True
End With
End Sub
Function Stdev()
Dim answer As Double
Dim myRange As Range
Set myRange = Application.Selection
On Error GoTo BadValue
answer = Application.WorksheetFunction.Stdev(myRange)
MsgBox Prompt:=answer, Title:="Standard Deviation"
Exit Function
BadValue:
MsgBox Prompt:="No range selected", Buttons:=vbCritical, Title:="ERROR"
Exit Function
End Function
Function Var()
Dim answer As Double
Dim myRange As Range
Set myRange = Application.Selection
On Error GoTo BadValue
answer = Application.WorksheetFunction.Var(myRange)
MsgBox Prompt:=answer, Title:="Variance"
Exit Function
BadValue:
MsgBox Prompt:="No range selected", Buttons:=vbCritical, Title:="ERROR"
Exit Function
End Function
Function Median()
Dim answer As Double
Dim myRange As Range
On Error GoTo BadValue
Set myRange = Application.Selection
answer = Application.WorksheetFunction.Median(myRange)
MsgBox Prompt:=answer, Title:="Median"
Exit Function
BadValue:
MsgBox Prompt:="No range selected", Buttons:=vbCritical, Title:="ERROR"
Exit Function
End Function
Function Std_Error()
Dim answer As Double
Dim myRange As Range
Set myRange = Application.Selection
On Error GoTo BadValue
answer = ((Application.WorksheetFunction.Stdev(myRange)) / (Sqr(Application.WorksheetFunction.CountA(myRange))))
MsgBox Prompt:=answer, Title:="Standard Error"
Exit Function
BadValue:
MsgBox Prompt:="No range selected", Buttons:=vbCritical, Title:="ERROR"
Exit Function
End Function
Thanks so much for any advice,
Carol
Bookmarks