• 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
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Macro - summarize data from two tabs in one|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Macro - summarize data from two tabs in 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 & MacrosMacro - summarize data from two tab…
sp_PrintTopic sp_TopicIcon
Macro - summarize data from two tabs in one
Avatar
Nadia Hurynovich
Member
Members
Level 0
Forum Posts: 6
Member Since:
September 28, 2018
sp_UserOfflineSmall Offline
1
July 24, 2019 - 7:27 am
sp_Permalink sp_Print

Hi,

I have a Macro that is supposed to copy data from NewData#1 tab and NewData#2 tab and summarize in the SummaryData tab. I used Relative References to record this Macro. However, when i added new lines in the #1 and #2 tabs "see them in yellow" only new lines from tab#2 are reflected in the  SummaryData tab after i run the Macro. Could you please help me fix the code in order to summarize all lines from both tabs even after new lines are added? Worksheet is attached 

Thanks a lot

Nadia 

sp_AnswersTopicSeeAnswer See Answer
Avatar
adrian@utas
University of Tasmania
Member
Members
Level 0
Forum Posts: 16
Member Since:
July 13, 2016
sp_UserOfflineSmall Offline
2
July 25, 2019 - 5:34 am
sp_Permalink sp_Print sp_EditHistory

Hello Nadia,

 

Your Macro looks great, but there are a couple of lines causing you issues.

Whilst it does successfully copy all data from both tabs, when it is pasting the second lot of data, it is pasting over the top of those last two lines from the first set. The reason for this is an errant line in the code: "Range("A17").Select". You also have a line before that which is hunting for the bottom of the list: "Range(Selection, Selection.End(xlDown)).Select" however a small adjustment will prevent that from being a selection of a range and instead a location of the first empty cell in the column (which of course uses the offset like you had in your code)

I have removed "Range("A17").Select" from your code and adjusted the xlDown/Offset code below, so I believe it will work now.

'
Range("A4").Select
Sheets("NewData#1").Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SummaryData").Select
ActiveSheet.Paste
Sheets("NewData#2").Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SummaryData").Select
Range("A4").End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste

Cheers,

Adrian

sp_AnswersTopicAnswer
Answers Post
Avatar
Nadia Hurynovich
Member
Members
Level 0
Forum Posts: 6
Member Since:
September 28, 2018
sp_UserOfflineSmall Offline
3
July 26, 2019 - 12:19 am
sp_Permalink sp_Print

It worked perfectly! Thank you so much 

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Richard West, Wesley Burchnall, Clayton Watson
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 204
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Bhuwan Devkota
Kathryn Patton
Maria Conatser
Jefferson Granemann
Glen Coulthard
Nikki Fox
Rachele Dickie
Forum Stats:
Groups: 3
Forums: 24
Topics: 6222
Posts: 27291

 

Member Stats:
Guest Posters: 49
Members: 31913
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.