Results 1 to 2 of 2

Simplifying VBA to a One Click Button

Threaded View

  1. #1
    Registered User
    Join Date
    01-16-2014
    Location
    Cardiff, Wales
    MS-Off Ver
    Excel 2010
    Posts
    1

    Simplifying VBA to a One Click Button

    Hi All,

    I have a member of this forum for a while and have sat on the fringes and "watched" so to speak. I now have a query that I would like some assistance with though;

    I have the following VBA code from one that was published here;

    Sub MergeSheets()
    
       ' Appends data from all the selected worksheets onto the end of the
       ' active worksheet.
       
       Const NHR = 1 'Number of header rows to not copy from each MWS
       
       Dim MWS     As Worksheet 'Worksheet to be merged (appended)
       Dim AWS     As Worksheet 'Worksheet to which the data are transferred
       Dim FAR     As Long 'First available row on AWS
       Dim LR      As Long 'Last row on the MWS sheets
       Dim MWSR    As Range 'Range to copy from MWS to AWS
       
       Set AWS = ActiveSheet
       
       For Each MWS In ActiveWindow.SelectedSheets
          If Not MWS Is AWS Then
             FAR = AWS.UsedRange.Cells(AWS.UsedRange.Cells.Count).row + 1
             LR = MWS.UsedRange.Cells(MWS.UsedRange.Cells.Count).row
             Set MWSR = MWS.Range(MWS.Rows(NHR + 1), MWS.Rows(LR))
             'limit range to cells within the usedrange
             Set MWSR = Application.Intersect(MWSR, MWS.UsedRange)
             MWSR.Copy
             AWS.Select     'Select AWS to cause de-select of MWS before paste
             'Range(Rows(FAR), Rows(FAR + LR)).Select
             Range(Cells(FAR, 1), Cells(FAR + MWSR.Rows.Count - 1, MWSR.Columns.Count)).Select
             ActiveSheet.PasteSpecial , True
                   End If
       Next MWS
    
    End Sub
    This is great but I am now handing the project over and would like to simplify the process. At present I have to highlight all the relevant sheets (all but 5)and then run the macro, then convert the consolidated data into a table.

    I would like to use a simple button that the new users can use to run this process. Does anyone have any suggestions at to how I might do this?

    Thanks for taking the time.
    Last edited by wells2014; 10-30-2014 at 08:23 AM. Reason: Lack of Code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Hide And Unhide Column With One Button,,,,Once Click Hide,,,,,Again Click Unhide
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2014, 07:58 AM
  2. [SOLVED] click on a color button and after button click it will color entire row of cell you click
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-11-2014, 06:06 PM
  3. [SOLVED] How do I run the macro for a button click without clicking the button?
    By flyboy54 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-12-2012, 10:45 AM
  4. Call button click event from a button on anther sheet
    By ajaykgarg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-25-2010, 09:27 AM
  5. [SOLVED] Create floating button based on button click in menu
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2005, 02:05 PM

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