+ Reply to Thread
Results 1 to 4 of 4

Excel 2000 macro to Excel 2016

  1. #1
    Registered User
    Join Date
    06-04-2019
    Location
    Raleigh, NC
    MS-Off Ver
    Office 2016
    Posts
    2

    Excel 2000 macro to Excel 2016

    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

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Excel 2000 macro to Excel 2016

    Some old macros will run in newer versions, but others which use old Excel objects that do not exist in the current version will need to be updated to use curren object names and attributes. One way to do the updates is to try and run the macro and as the code errors, fix the object or property that the new version does not like. In some cases, it might be easier to write new code altogether, but I would take it on a case by case basis. You can always post back to the forum for help on specific problems, but I don't believe anyone wants to take on the task of re-writing your macros for you.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Excel 2000 macro to Excel 2016

    Quote Originally Posted by CAAE View Post
    ... but no longer work ...
    This way of calling a new/user menu should work in the old and new excel (although it does not have to), try it:

    1. ThisWorkbook module:
    Please Login or Register  to view this content.
    2. Standard module, e.g. Module1:
    Please Login or Register  to view this content.
    3. You can also simplify functions calls a little and shorten them to one function, e.g.:
    (in standard module Module1 also)
    Please Login or Register  to view this content.
    But do not treat it as a solution to your problem, but an attempt to solve it, an example.

    After starting the workbook, a new icon should appear in the main menu named "Extras" or "Add-Ins", don't know which one.
    Your new menu for statistics will be located there ... maybe ...

    Ps.:
    Do not use the names of the excel functions to name the udf functions, because in some cases will be one big ... "big ben", i.e. boom boom ... ... with calculations.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by mjr veverka; 06-04-2019 at 10:40 PM.

  4. #4
    Registered User
    Join Date
    06-04-2019
    Location
    Raleigh, NC
    MS-Off Ver
    Office 2016
    Posts
    2

    Re: Excel 2000 macro to Excel 2016

    My thanks for your fast replies to my post and very helpful expert advice!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro built in Excel 2011 crashes workbook in Excel 2016
    By NCRB_10 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-24-2018, 12:31 AM
  2. Replies: 1
    Last Post: 09-18-2017, 08:27 AM
  3. macro: excel 2003(run) to excel 2016(problem)
    By brianjj in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 01-19-2017, 01:15 PM
  4. Problems when using macro created in Excel 2000, in Excel 2003
    By Vlada in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2006, 11:24 AM
  5. macro which works in excel 2000 does not work in excel 2002
    By nnayak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2006, 09:17 AM
  6. [SOLVED] Run time error : Excel 2000 and Excel 2003 : different behavior of Macro
    By Bala in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2006, 12:20 AM
  7. Replies: 0
    Last Post: 09-27-2005, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1