• 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

Merge few cell of rows in separate column. |VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Merge few cell of rows in separate column. |VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
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 & MacrosMerge few cell of rows in separate …
sp_PrintTopic sp_TopicIcon
Merge few cell of rows in separate column.
Avatar
Mariya Abdu Hamid
Member
Members
Level 0
Forum Posts: 15
Member Since:
September 8, 2018
sp_UserOfflineSmall Offline
1
September 8, 2018 - 11:49 pm
sp_Permalink sp_Print sp_EditHistory

Hi all,

How do I to merge few cells of rows in separate column as explained below ?

For instance, I have table. I want to merge each column until last row in column E. See after and before image below.

BEFORE :

before.PNGImage Enlarger

AFTER :

after.PNGImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage before.PNG (8 KB)
  • sp_PlupImage after.PNG (8 KB)
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
September 10, 2018 - 1:35 am
sp_Permalink sp_Print

Hi Mariya

Just select A2:A4 and then press the Merge & Centre cells icon on the ribbon.

Repeat for cells B2:B4, C2:C2 and D2:D4. You can then adjust the text to Middle Align.

Sunny

Avatar
Mariya Abdu Hamid
Member
Members
Level 0
Forum Posts: 15
Member Since:
September 8, 2018
sp_UserOfflineSmall Offline
3
September 11, 2018 - 1:51 pm
sp_Permalink sp_Print

Hi Sunny,

 

Thanks for your respond.

But anyway, is that possible to have VBA code for this case ?

 

Thanks.

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
4
September 12, 2018 - 3:37 am
sp_Permalink sp_Print sp_EditHistory

Why do you need a macro when you can easily do it just using Excel?

Avatar
Mariya Abdu Hamid
Member
Members
Level 0
Forum Posts: 15
Member Since:
September 8, 2018
sp_UserOfflineSmall Offline
5
September 15, 2018 - 9:55 pm
sp_Permalink sp_Print

Hi Sunny,

 

Sorry for tardy reply.

It works ! But unfortunately when I try to continue new entry, it doesn't work 🙁

See photo. Could you please hep me on this ? Appreciate your advice !

new-entry.PNGImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage new-entry.PNG (15 KB)
Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
6
September 16, 2018 - 4:18 am
sp_Permalink sp_Print

Hi Mariya

You can give this a try.

You will need to select the required range one by one (eg A2:D4) before clicking the MERGE button.

Then continue with selecting A5:D6 etc

Hope this helps.

Sunny

Avatar
Mariya Abdu Hamid
Member
Members
Level 0
Forum Posts: 15
Member Since:
September 8, 2018
sp_UserOfflineSmall Offline
7
September 17, 2018 - 11:00 am
sp_Permalink sp_Print

Hi Sunny,

This is not what I need 🙁

The concept of this is, user will key in data thru Userform and the data will transfer to worksheet automatically by pressing command button.

My intention of this merge is, it will automatically execute the merge after transferring data from Userform to worksheet. 

Is it possible ? 🙁

Appreciate your advice. 

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1530
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
8
September 17, 2018 - 1:24 pm
sp_Permalink sp_Print

Hi Mariya,

You should have said this in your original post.

Have you written the userform and code that writes the data to the sheet?  If so you just need to modify this to carry out the merge on the relevant cells.

If you haven't yet started the form you may find these posts useful

https://www.myonlinetraininghu...../userforms

but start with this one

https://www.myonlinetraininghu.....xcel-forms

If you can supply a workbook with a form and code behind it we can look to modify as needed to achieve the cell merge you want.

regards

Phil

Avatar
Mariya Abdu Hamid
Member
Members
Level 0
Forum Posts: 15
Member Since:
September 8, 2018
sp_UserOfflineSmall Offline
9
September 19, 2018 - 5:50 pm
sp_Permalink sp_Print

Hi Phil/Sunny,

 

Kindly below attached for your review. Really appreciate your help. Thanks !

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
10
September 20, 2018 - 2:12 am
sp_Permalink sp_Print

Hi Mariya

Try this. I have corrected a bug in your code that will cause an error when the qty doesn't tally.

It tried to select textbox10 that is disabled.

Hope this helps.

Sunny

sp_AnswersTopicAnswer
Answers Post
Avatar
Mariya Abdu Hamid
Member
Members
Level 0
Forum Posts: 15
Member Since:
September 8, 2018
sp_UserOfflineSmall Offline
11
September 20, 2018 - 11:17 am
sp_Permalink sp_Print

Hi Sunny,

The merge is works, thanks for the code !! but unfortunately debug error will come out if quantity does not tally.

What should I do to overcome this issue ?

Thanks for your advice !

 

Debug-Error.PNGImage Enlarger

Debug-Error0.PNGImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage Debug-Error.PNG (8 KB)
  • sp_PlupImage Debug-Error0.PNG (7 KB)
Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
12
September 20, 2018 - 5:08 pm
sp_Permalink sp_Print

Hi Mariya

As I mentioned earlier, your original code tried to select TextBox10 which is disabled by you.

So I changed it to select Textbox1 instead. Just add the text in red below.

If Val(UserForm1.TextBox9) <> totalDefect Then
MsgBox ("QUANTITY DEFECT NOT SAME !"), vbCritical, "VERIFICATION"
' TextBox10.SetFocus 'this gives a error if qty doeant tally as it is disabled
TextBox1.SetFocus
Exit Sub
Else

Hope this helps.

Sunny

Avatar
Mariya Abdu Hamid
Member
Members
Level 0
Forum Posts: 15
Member Since:
September 8, 2018
sp_UserOfflineSmall Offline
13
September 20, 2018 - 8:33 pm
sp_Permalink sp_Print

Hi Sunny,

It's really works after I add in "Exit Sub" as per your advised !! Love it !!

Thanks anyway 🙂 🙂 🙂

Avatar
mymalone
Member
Members
Level 0
Forum Posts: 104
Member Since:
August 25, 2017
sp_UserOfflineSmall Offline
14
October 6, 2018 - 2:56 am
sp_Permalink sp_Print

Sunny

Wow!!  Awesome!  I really like this format. What is it called?  I like the entire setup. 

I can see a lot of potential for this format.

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


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

Hi Melinda

Glad you liked it.Laugh

Hope you will find a lot of use with it.

Sunny

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Velouria, jonhn wikal, David du Toit
Guest(s) 9
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: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Karen Newman
Aminu Sule
Samuel Ramirez
Abdifatah Osman
mohad borhom
Abayomi Adedeji
Ganesh MVS
Gilbert Lemek
Ashleigh Farquharson
Jayz Luu
Forum Stats:
Groups: 3
Forums: 24
Topics: 6364
Posts: 27829

 

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