Results 1 to 3 of 3

VBA that edits an existing VBA by using (I think) an Active X command button

Threaded View

  1. #1
    Registered User
    Join Date
    07-20-2015
    Location
    New York
    MS-Off Ver
    2305 - Enterprise 365
    Posts
    162

    Smile VBA that edits an existing VBA by using (I think) an Active X command button

    Hello All,
    I have completed my AMEX subtotal macro, but need to add one more feature. If my company has a new card member, I need to add that person to the existing vba code plus I need to increase the number by one of his/her replacement "name". I want to be able to edit the code at the touch of either a form control button or an active x button, whichever works. The form control/active x button will trigger a pop up message window that shows the following:
    "Do you want to add this person's name?"
    The user must enter the new person's name in the field below. In this case, it is: Patrick H. Henry
    Below that, the user will have the option to click "Yes" or "Cancel"

    If the user clicks, "Yes", the code will be added to the macro named "AM_namestonumbersandnames". This macro can also be found on the sheet attached. Note that I have not edited the macro.

    Here is my wished for code of "AM_namestonumbersandnames" if the user clicks on the "yes" button on the pop up message window:

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Sub AM_namestonumbersandnames()
    '
    ' AM_namestonumbersandnames Macro
    '
    
    '
        Application.CutCopyMode = False
        Selection.Copy
        Cells.Replace What:="Jack A Jill", Replacement:="1Jack A Jill", LookAt _
            :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        ActiveWindow.SmallScroll Down:=42
        Range("D48").Select
        Application.CutCopyMode = False
        Selection.Copy
        Cells.Replace What:="Charles A Charles", Replacement:="2Charles A Charles", _
            LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
            False, ReplaceFormat:=False
        ActiveWindow.SmallScroll Down:=27
        Range("D76").Select
        Application.CutCopyMode = False
        Selection.Copy
        Cells.Replace What:="Charles X Xylophone", Replacement:="3Charles X Xylophone", _
            LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
            False, ReplaceFormat:=False
        Range("D75").Select
        Application.CutCopyMode = False
        Selection.Copy
        Cells.Replace What:="Dafne A Duck", Replacement:="4Dafne A Duck", _
            LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
            False, ReplaceFormat:=False
        ActiveWindow.SmallScroll Down:=51
        Range("D124").Select
        Application.CutCopyMode = False
        Selection.Copy
        Cells.Replace What:="Joshua A Tree", Replacement:="5Joshua A Tree", LookAt _
            :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        ActiveWindow.SmallScroll Down:=9
        Range("D135").Select
        Application.CutCopyMode = False
        Selection.Copy
        Cells.Replace What:="Mark A Mark", Replacement:="6Mark A Mark", _
            LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
            False, ReplaceFormat:=False
            Selection.Copy
        Cells.Replace What:="Charles Refined", Replacement:="8Charles Refined", _
            LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
            False, ReplaceFormat:=False
            Selection.Copy
        Cells.Replace What:="James A Kake", Replacement:="9James A Kake", _
            LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
            False, ReplaceFormat:=False
    Cells.Replace What:="Patrick H Henry", Replacement:="10Patrick H Henry", _
            LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
            False, ReplaceFormat:=False
    End Sub
    Note the code in bold. Not only have I added a new name to the code but I have increased the number before his name by one from the previous name. (i.e. "9James A Kake" to "10Patrick H Henry") This way I can sort his name in accordance with the original AMEX statement order. Any future names must also increase by one whole number. Therefore, the next added card member will have an eleven added to the code and the one after that will have a twelve added and so forth and so on. Therefore the button must have a counter.

    If anyone out there can add code to the existing code via the use of a button, that would be most helpful. I have added an active x button to the attached worksheet called "Add a new card member?" as an example only. You may edit it/change it at will and it is not assigned to any macros.

    Thanking you in advance for your help.

    Best,
    AndrewTemplate for Forum.xlsm
    Last edited by 6StringJazzer; 07-27-2015 at 02:42 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Adding command button to existing multipage
    By nicksyplonk in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-19-2015, 05:25 AM
  2. [SOLVED] Active X Command Button not working
    By gassiusmax in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-04-2015, 01:29 PM
  3. Using an Active X Command Button
    By Scottmcq12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2014, 05:04 AM
  4. [SOLVED] Active Command Button Properties
    By Usethaschwarz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-15-2012, 08:47 AM
  5. Command Button That Opens Existing Worksheet In New Window
    By nevi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-06-2012, 04:02 PM
  6. Tab sequence from cell to active x button and then to a command button
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2009, 02:27 PM
  7. Adding Code to an Existing Command Button with VBA
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2005, 11:36 AM

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