Forum

Merge few cell of r...
 
Notifications
Clear all

Merge few cell of rows in separate column.

15 Posts
4 Users
0 Reactions
71 Views
(@mariyaulfa92)
Posts: 14
Eminent Member
Topic starter
 

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.PNG

AFTER :

after.PNG

 
Posted : 09/09/2018 9:49 am
(@sunnykow)
Posts: 1417
Noble Member
 

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

 
Posted : 10/09/2018 11:35 am
(@mariyaulfa92)
Posts: 14
Eminent Member
Topic starter
 

Hi Sunny,

 

Thanks for your respond.

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

 

Thanks.

 
Posted : 11/09/2018 11:51 pm
(@sunnykow)
Posts: 1417
Noble Member
 

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

 
Posted : 12/09/2018 1:37 pm
(@mariyaulfa92)
Posts: 14
Eminent Member
Topic starter
 

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.PNG

 
Posted : 16/09/2018 7:55 am
(@sunnykow)
Posts: 1417
Noble Member
 

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

 
Posted : 16/09/2018 2:18 pm
(@mariyaulfa92)
Posts: 14
Eminent Member
Topic starter
 

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. 

 
Posted : 17/09/2018 9:00 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

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.myonlinetraininghub.com/tag/userforms

but start with this one

https://www.myonlinetraininghub.com/excel-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

 
Posted : 17/09/2018 11:24 pm
(@mariyaulfa92)
Posts: 14
Eminent Member
Topic starter
 

Hi Phil/Sunny,

 

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

 
Posted : 20/09/2018 3:50 am
(@sunnykow)
Posts: 1417
Noble Member
 

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

 
Posted : 20/09/2018 12:12 pm
(@mariyaulfa92)
Posts: 14
Eminent Member
Topic starter
 

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.PNGDebug-Error0.PNG

 
Posted : 20/09/2018 9:17 pm
(@sunnykow)
Posts: 1417
Noble Member
 

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

 
Posted : 21/09/2018 3:08 am
(@mariyaulfa92)
Posts: 14
Eminent Member
Topic starter
 

Hi Sunny,

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

Thanks anyway 🙂 🙂 🙂

 
Posted : 21/09/2018 6:33 am
(@mymalone)
Posts: 103
Estimable Member
 

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.

 
Posted : 06/10/2018 12:56 pm
(@sunnykow)
Posts: 1417
Noble Member
 

Hi Melinda

Glad you liked it.Laugh

Hope you will find a lot of use with it.

Sunny

 
Posted : 06/10/2018 7:27 pm
Share: