merge cells with reference to other cells

noubaba

New Member
Joined
Apr 10, 2018
Messages
19
Hi,
I need help to merge fruits named cell with refence to other cells. Follows I explained with example what I want to do with formula or with few clicks. Actually I am extracting huge data from SAP and SAP giving me fruits names in different rows in front of each country name and codes, countries names could be duplicated but coded are unique, and I want to merge fruit names in one cell as I merge them manually in last cell. Can you please help me to develop a formula or trick for this task. Formula can read codes or read country name like USA and then merge next cells till blanks cells under USA or Brazil.
this what I want to do
1002323USAappleapple
mango
Guava
Litchi
mango
Guava
Litchi
10025454Brazilappleapple
Jackfruit
Orange
Banana
Jackfruit
Orange
Banana
 
This Macro working fine for first few cells, but Still I am getting some error on other cells, as I copy paste bellow. please refer attached photo for further clarifications. Can you please fix it further, thanks in advance.

IDCountryItemsMacro ResultShould supposed to be like this
1002323USAappleapple
mango
Guava
Litchi
apple
mango
Guava
Litchi
mango
Guava
Litchi
10025454Brazilappleapple
Jackfruit
Orange
Banana
apple
Jackfruit
Orange
Banana
Jackfruit
Orange
Banana
1008655UKBananaBanana
Banana
Jackfruit
mango
Banana
Banana
Jackfruit
mango
mango
Banana
Jackfruit
mango
mangomango
aa
bb
cc
10022324Country-1aaaa
bb
cc
dd
ee
ff
ff
aa
bb
cc
dddd
ee
ff
ff
ee
ff
ff
aaaa

 

Attachments

  • Error.JPG
    Error.JPG
    78.5 KB · Views: 1
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Issue is your data in your first two presentations showed only 4 lines to consolidate. Again, we assume that the data you present is representative of your actual data. You have not done this. Your data that you are working with has more or less lines of data. How are we to know this. Code that I established was based upon your presentation of 4 lines. Will look at this as I have time and see if I can supply you with a solution. You really need to work with us and give us true representations of your actual data or we will be playing these catch up games all day. Since we are now working with more data -- please use the XL2BB function to upload your sample data. It is impossible to manipulate data in pictures.
 
Upvote 0
Sorry to bother you with my data, actually this is just an example not representing my actual data. Actually I am extracting huge data from system on daily basis, and I am in need to merge "Items" in "C" column as I mentioned in column F, In short I want to merge column "C" items to column "F"as uploaded my sample data and these "Items" in column "C" having more and less lines and so on. Really appreciate if you help me to derive a perfect formula or macro to do this task.
how merge cells.xlsm
ABCDEF
1IDCountryItemsgiven Macro ResultShould supposed to be like this
21002323USAappleapple mango Guava Litchiapple mango Guava Litchi
3mango
4Guava
5Litchi
610025454Brazilappleapple Jackfruit Orange Bananaapple Jackfruit Orange Banana
7Jackfruit
8Orange
9Banana
101008655UKBananaBanana Banana Jackfruit mangoBanana Banana Jackfruit mango mango
11Banana
12Jackfruit
13mango
14mangomango aa bb cc
1510022324Country-1 aaaa bb cc dd ee ff ff aa
16bb
17cc
18dddd ee ff ff
19ee
20ff
21ff
22aaaa
Sheet1
 
Upvote 0
Sorry, I have spent an hour on this with no success. Hopefully, someone with more VBA knowledge will come here. I'm out of time.
 
Upvote 0
What version of Excel are you using?
Please update your account details to show this. Thanks
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,945
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top