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 :
AFTER :
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
Hi Sunny,
Thanks for your respond.
But anyway, is that possible to have VBA code for this case ?
Thanks.
Why do you need a macro when you can easily do it just using Excel?
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 !
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
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.
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
Hi Phil/Sunny,
Kindly below attached for your review. Really appreciate your help. Thanks !
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
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 !
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
Hi Sunny,
It's really works after I add in "Exit Sub" as per your advised !! Love it !!
Thanks anyway 🙂 🙂 🙂
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.
Hi Melinda
Glad you liked it.
Hope you will find a lot of use with it.
Sunny