VBA Help with Merging Cells Based on Conditions

sax2play

Board Regular
Joined
Mar 13, 2021
Messages
63
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I am struggling to even get started on this VBA code...some help would be greatly appreciated!

I am trying to write a VBA to reformat and merge data in an excel sheet to a specific format. The number of lines and the data always changes. Here is an example of how the original data appears:

Rich (BB code):
Line​
Source​
1​
AOS​
2​
IPC​
3​
U013100​
4​
CSM​
5​
TCM​
6​
CGM​
7​
EBCM_Base​
8​
U013100​
9​
RDCM/TCCM​
10​
HVAC_FP_F_Base​
11​
SCL_Base​
12​
FCM​
13​
ECM​
14​
P062F00​
15​
U056600​
16​
TCP​

This is how the data needs to be formatted after running the macro:

Rich (BB code):
Line​
Source​
1​
AOS​
2​
IPC​
3​
IPCU0131.00
4​
CSM​
5​
TCM​
6​
CGM​
7​
EBCM_Base​
8​
EBCU0131.00
9​
RDCM/TCCM​
10​
HVAC_FP_F_Base​
11​
SCL_Base​
12​
FCM​
13​
ECM​
14​
ECMP062F.00
15​
ECMU0566.00
16​
TCP​

Here's the part where I'm struggling and why I do not know how to start:

The number of alpha-numeric rows below each subheading (AOS, IPC, FCM, ECM, etc.) varies. Sometimes, there may not be any alpha-numeric data below a "subheading" and sometimes there will be multiple lines. When there is alpha-numeric data below a subheading, I need it to be combined with the subheading and then the last two digits of the alpha-numeric data needs to be separated by a period. I highlighted the data that changed above in RED. If needed, another column can be added for the merged data, or it can remain in the same cell, but it needs to remain in the same row.

Any help to get me started would be extremely appreciated!!

Thanks in advance!!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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