Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2016, 05:56 PM
jimmy2016 jimmy2016 is offline Combining different worksheets into a single worksheet. Windows 10 Combining different worksheets into a single worksheet. Office 2016
Novice
Combining different worksheets into a single worksheet.
 
Join Date: Sep 2016
Location: Hong Kong
Posts: 8
jimmy2016 is on a distinguished road
Default Combining different worksheets into a single worksheet.

Dear helpers,



I am new to VBA and have the problem:
To combine worksheets into a single worksheet we always use copy and paste but if there are many worksheets, say 30, it will spend a lot of time in selecting and copying.
I want to create a button in sheet1 and onclick it, those tables in the worksheets(named A01,..,A30) will be copied to sheet1, say from sheet1!A15.

1. The worksheets will be of the same number of columns:
A1(name), B11(date), C11(number), D11(price)
but different rows of data.

2. In the workbook, there are other worksheets and the worksheets I want to cope with are A01,...A30 only.

3. The are other data in worksheets A01,...,A30 and the tables I want to copy are, say, A01!A11:P19, A02!A11:P13,....
Can the VBA code count the number of rows in the table in each worksheet?

Thanks for your help.
Reply With Quote
  #2  
Old 10-13-2016, 12:47 PM
charlesdh charlesdh is offline Combining different worksheets into a single worksheet. Windows 7 32bit Combining different worksheets into a single worksheet. Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

Hi,

Can you post a workbook. This will help.
Supply a example as to what you want too see.
Reply With Quote
  #3  
Old 10-14-2016, 12:27 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Combining different worksheets into a single worksheet. Windows 7 64bit Combining different worksheets into a single worksheet. Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Why not try this add-in from Ron de Bruin ?
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #4  
Old 10-14-2016, 02:01 AM
jimmy2016 jimmy2016 is offline Combining different worksheets into a single worksheet. Windows 10 Combining different worksheets into a single worksheet. Office 2016
Novice
Combining different worksheets into a single worksheet.
 
Join Date: Sep 2016
Location: Hong Kong
Posts: 8
jimmy2016 is on a distinguished road
Default This is what i want

Combine sheets A01 .... A04 into Sheet1
Attached Files
File Type: xlsx samplefile.xlsx (12.2 KB, 8 views)
Reply With Quote
  #5  
Old 10-15-2016, 09:05 AM
NoSparks NoSparks is offline Combining different worksheets into a single worksheet. Windows 7 64bit Combining different worksheets into a single worksheet. Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Something along the lines of this should do it.
Hopefully you can follow the commenting.
Code:
Sub CombineJimmysSheets()
    
Dim i As Integer, sht As Worksheet, RngLR As Long
    
Application.ScreenUpdating = False
'loop thru numbers
For i = 1 To 30
    'loop thru sheets
    For Each sht In ThisWorkbook.Sheets
        'if sheet name found
        If sht.Name = "A" & Format(i, "00") Then
            With sht
                'determine last row of range
                RngLR = .Range("A4").End(xlDown).Row
                'copy the range and paste to sheet 1
                .Range("A5:P" & RngLR).Copy _
                Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1)
            End With
            'don't loop any further looking for sheet already found
            Exit For
        End If
    'check next sheet
    Next sht
'check for next number
Next i
Application.ScreenUpdating = True
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining different worksheets into a single worksheet. Combine values from different worksheets into a single worksheet. jimmy2016 Excel 2 10-06-2016 09:15 AM
How do I populate Worksheets using information entirely from another Worksheet in the same Workbook? BrieDanielle Excel 1 06-18-2016 10:50 AM
Combine or merge multiple worksheets into one worksheet timomaha Excel 1 07-21-2014 01:02 PM
Combining different worksheets into a single worksheet. Multiple Dynamic Worksheets Consolidated into One Static Worksheet mars1886 Excel Programming 3 02-09-2014 12:50 AM
Combining different worksheets into a single worksheet. Cells from other worksheets apear on current worksheet Equilar Excel 3 05-03-2010 01:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:57 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft