• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

VBA to copy all worksheets into one|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / VBA to copy all worksheets into one|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosVBA to copy all worksheets into one
sp_PrintTopic sp_TopicIcon
VBA to copy all worksheets into one
Avatar
Amy 73
Member
Members
Level 0
Forum Posts: 39
Member Since:
February 11, 2015
sp_UserOfflineSmall Offline
1
October 4, 2018 - 7:18 am
sp_Permalink sp_Print

Hello

Good afternoon.

I would love some help writing a macro that does the following:

Copy’s all worksheets into one “Summary Tab”, with the exception of the Drop List tab. I will be adding new tabs each week, so I will have re-run this macro weekly as well.  I would like for it to replace the old information.

All the headers are the same, so I only need the header columns listed once at the top of the list.

Any help would be greatly appreciated.

 Thanks

Amy

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
2
October 4, 2018 - 2:17 pm
sp_Permalink sp_Print

Hi Amy

Give this a try.

Please note that for any additional sheet to be added and merged, the sheet's name must contain the text "Scrap Report"

The macro will search thru all sheets and will only merge those sheet names containing the text "Scrap Report".

The macro will clear the Summary Tab data (excluding the header) before merging.

Hope this helps.

Sunny

Avatar
Amy 73
Member
Members
Level 0
Forum Posts: 39
Member Since:
February 11, 2015
sp_UserOfflineSmall Offline
3
October 4, 2018 - 10:12 pm
sp_Permalink sp_Print

Sunny

Wow! Thank you so much.  This is awesome.  This will save me so much time.

I have a question on the formula?

 With this, does this mean something has to be in column B for it to pull over onto the summary tab?

Find the last row with data

            LastSrc = ws.Cells(Rows.Count, "B").End(xlUp).Row 'Weekly sheet

Also, can you explain this code as well?  What does the “A” do?

CopyRng.Copy

                With DestSh.Cells(LastTgt + 1, "A")

I’m trying to learn VBA, put it’s a struggle.

Thank you again for taking the time to help me with this.

Sincerely

Amy

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
4
October 5, 2018 - 9:17 am
sp_Permalink sp_Print sp_EditHistory

Hi Amy

Glad you like the macro.

The code LastSrc = ws.Cells(Rows.Count, "B").End(xlUp).Row search for the last row with data in column B.

You can use any column of your choice but make sure that it does not have any blanks.

I did not choose column A in your example as I noticed that in your Scrap Report Week 1 sheet, my macro would have given me 3 as the last row instead of 4 due to the blank in cell A4.

In the code With DestSh.Cells(LastTgt + 1, "A")  , A is the column as the syntax is CELLS(row,column). Both row and column can be a number but column can also be an alphabet like this case.

The code  If LastSrc >= StartTgt checks to see if the last row is the same or more than the start row which I set to 3 in your example.

If it is more than or equal to 3 then it must contain data and the data will be copied, else that sheet will be ignored.

Hope this explanation is clear enough.

Sunny

Avatar
Amy 73
Member
Members
Level 0
Forum Posts: 39
Member Since:
February 11, 2015
sp_UserOfflineSmall Offline
5
October 22, 2018 - 9:18 am
sp_Permalink sp_Print

Sunny

Thanks again.  I have one more thing I would like to add to the macro, if possible? On the Summary Tab, is there a way to highlight the cell in the RGA # column (K) if the cell is blank,  but only if the Disposition column (J) is Vendor Credit / Return.  This way I know I have to get a RGA from the customer. 

Thanks so much

Amy

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
6
October 22, 2018 - 10:37 am
sp_Permalink sp_Print

Hi Amy

Not sure if your "blank" means a totally blank cell or 0 (or something else).

I set it to check for blank cell .i.e. = ""

You can change it to = 0 if you like.

It will highlight the cell in yellow.

Hope this helps.

Sunny

Avatar
Amy 73
Member
Members
Level 0
Forum Posts: 39
Member Since:
February 11, 2015
sp_UserOfflineSmall Offline
7
October 22, 2018 - 10:23 pm
sp_Permalink sp_Print

Sunny

You are amazing!  Thank you so much!   

Amy

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
8
October 23, 2018 - 8:47 am
sp_Permalink sp_Print

Hi Amy

Thanks for your feedback.

Happy to know it is working for you.

Sunny

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Mynda Treacy
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 215
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Ngoc Qui Nguyen
Clement Mansfield
Rose .
Bindu Menon
Baruch Zemer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6352
Posts: 27779

 

Member Stats:
Guest Posters: 49
Members: 32319
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.