• 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
  • Login

Merging separate columns of data |VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Merging separate columns of data |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 & MacrosMerging separate columns of data
sp_PrintTopic sp_TopicIcon
Merging separate columns of data
Avatar
MrAhmed
Member
Members
Level 0
Forum Posts: 6
Member Since:
August 25, 2016
sp_UserOfflineSmall Offline
1
February 11, 2017 - 3:02 am
sp_Permalink sp_Print

Hi

im having trouble Merging separate columns of data in different sheets in to another sheet.

e.g. Column A in Sheet 1 and 2 has data, I want to combine the 2 columns of data in sheet 3.

In sheet 3, the data from sheet 2 needs to start from the end of the data from sheet 1.

the data in sheet 1 and 2 is not fixed, so the number of populated cells could change.

sp_AnswersTopicSeeAnswer See Answer
Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
2
February 11, 2017 - 10:42 am
sp_Permalink sp_Print

Hi

Give this a try

Sub MergeData()
Dim LastRow1 As Long
Dim LastRow2 As Long
Dim LastRow3 As Long
LastRow1 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
LastRow2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Sheet1").Range("A1:A" & LastRow1).Copy Sheets("Sheet3").Range("A1")
LastRow3 = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row + 1
Sheets("Sheet2").Range("A1:A" & LastRow2).Copy Sheets("Sheet3").Range("A" & LastRow3)
End Sub

Sunny

sp_AnswersTopicAnswer
Answers Post
Avatar
MrAhmed
Member
Members
Level 0
Forum Posts: 6
Member Since:
August 25, 2016
sp_UserOfflineSmall Offline
3
February 13, 2017 - 9:04 pm
sp_Permalink sp_Print

That's Brilliant Sunny. I really appreciate your help. Thanks.

if have time would you mind explaining what the code means, so I can understand how you did it?

Cheers

Ahmed.

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
4
February 14, 2017 - 1:42 am
sp_Permalink sp_Print

Hi Ahmed

See my explanation in red below.

Find the last row number of the sheets with data as I need to copy from Column A Row 1 till the last row containing data.

LastRow1 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row This will give me the last row number
LastRow2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row This will give me the last row number

Copy data from Sheet1, starting from Column A Row 1 till the last row with data to Sheet3. You can do this without needing to use the Copy and Paste command (like below)
Sheets("Sheet1").Range("A1:A" & LastRow1).Copy Sheets("Sheet3").Range("A1") 

Find out what is the next blank row (i.e. Last row number + 1 ) in Sheet3 after pasting data from Sheet1. I need it to append (add) data to the next blank row.
LastRow3 = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row + 1

Copy data from Sheet2 to next blank row in Sheet3
Sheets("Sheet2").Range("A1:A" & LastRow2).Copy Sheets("Sheet3").Range("A" & LastRow3)

Hope my explanation is clear.

Suny

Avatar
David_Ng
Member
Members
Level 0
Forum Posts: 306
Member Since:
December 5, 2016
sp_UserOfflineSmall Offline
5
February 14, 2017 - 3:58 pm
sp_Permalink sp_Print

Thanks Sunny [ Suny] I think you do give a very clear explanation of the VB code to everyone.

Now even layman can get an insight and understanding to know what these codes is getting at and accomplish for users. 

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
6
February 15, 2017 - 2:00 am
sp_Permalink sp_Print

Hi David

Thanks for your feedback. Glad to know the explanation is clear enough Smile

Sunny

Avatar
MrAhmed
Member
Members
Level 0
Forum Posts: 6
Member Since:
August 25, 2016
sp_UserOfflineSmall Offline
7
February 15, 2017 - 8:15 pm
sp_Permalink sp_Print

Thanks Sunny, that's exactly what I was after!

Ahmed (aka layman)

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Velouria, Mike Magill, Barbara Murray
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 185
Newest Members:
Kwaje Alfred Mogga
thong nguyen
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Rob Rooth
Forum Stats:
Groups: 3
Forums: 24
Topics: 6542
Posts: 28648

 

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

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • 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

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

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

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.