Macro - edit and reorder data into new cells

Crawtney

New Member
Joined
Apr 10, 2018
Messages
6
This a sample of the data that I have entered into Column A after opening an output from a third party program.
Nc1nc2c(ncn2C3CC(C=C3)CO)c(n1)NC4CC4 abacavir_DB01048_B3_TGA.smi_0

<colgroup><col width="571"></colgroup><tbody>
</tbody>
CC(N(O)C(=O)N)c1cc2ccccc2s1 zileuton_DB00744_C_FDA.smi_0

<colgroup><col width="571"></colgroup><tbody>
</tbody>
Clc1c(cc2c(c1)NC(=O)C2)CCN3CCN(CC3)c4nsc5c4cccc5 ziprasidone_DB00246_C_TGA.smi_0

<colgroup><col width="571"></colgroup><tbody>
</tbody>
OC(Cn1ccnc1)(P(=O)(O)O)P(=O)(O)O zoledronic-acid_DB00399_B3_TGA.smi_0

<colgroup><col width="571"></colgroup><tbody>
</tbody>
CN(C)CCc1c[nH]c2c1cc(cc2)CC3COC(=O)N3 zolmitriptan_DB00315_B3_TGA.smi_0

<colgroup><col width="571"></colgroup><tbody>
</tbody>
CN(C)C(=O)Cc1c(nc2n1cc(cc2)C)c3ccc(cc3)C zolpidem_DB00425_B3_TGA.smi_0

<colgroup><col width="571"></colgroup><tbody>
</tbody>

<tbody>
</tbody>


<tbody>
</tbody>














I would like to be able to run a macro so that it changes to this:
abacavir

<colgroup><col width="101"></colgroup><tbody>
</tbody>
DB01048

<colgroup><col width="64"></colgroup><tbody>
</tbody>
B3

<colgroup><col width="64"></colgroup><tbody>
</tbody>
TGA

<colgroup><col width="64"></colgroup><tbody>
</tbody>
zileuton

<colgroup><col width="101"></colgroup><tbody>
</tbody>
DB00744

<colgroup><col width="64"></colgroup><tbody>
</tbody>
C

<colgroup><col width="64"></colgroup><tbody>
</tbody>
FDA

<colgroup><col width="64"></colgroup><tbody>
</tbody>
ziprasidone

<colgroup><col width="101"></colgroup><tbody>
</tbody>
DB00246

<colgroup><col width="64"></colgroup><tbody>
</tbody>
C

<colgroup><col width="64"></colgroup><tbody>
</tbody>
TGA

<colgroup><col width="64"></colgroup><tbody>
</tbody>
zoledronic acid

<colgroup><col width="101"></colgroup><tbody>
</tbody>
DB00399

<colgroup><col width="64"></colgroup><tbody>
</tbody>
B3

<colgroup><col width="64"></colgroup><tbody>
</tbody>
TGA

<colgroup><col width="64"></colgroup><tbody>
</tbody>
zolmitriptan

<colgroup><col width="101"></colgroup><tbody>
</tbody>
DB00315

<colgroup><col width="64"></colgroup><tbody>
</tbody>
B3

<colgroup><col width="64"></colgroup><tbody>
</tbody>
TGA

<colgroup><col width="64"></colgroup><tbody>
</tbody>
zolpidem

<colgroup><col width="101"></colgroup><tbody>
</tbody>
DB00425

<colgroup><col width="64"></colgroup><tbody>
</tbody>
B3

<colgroup><col width="64"></colgroup><tbody>
</tbody>
TGA

<colgroup><col width="64"></colgroup><tbody>
</tbody>

<tbody>
</tbody>

The individual changes that need to be made are:
- removing the first string and it's ending space
- removing ".smi_0"
- inserting 3 cells to the right of the first one
- using the '_' as an indication to move data to the next column over
- making sure no underscores are left
- replace any '-' with a space

Please note that the first string of characters and the following drug name do not all have an equal number of characters.

How I've been doing it so far:
- Find and replace ' ' with '_'
- Find and delete '.smi_0'
- Replace '_' with ','
- Copy and paste data to a text file
- Save as .csv
- Insert new cells into my spreadsheet
- Clear the cells with the existing data
- Open and copy the .csv data back into my spreadsheet
- Find and replace '-' with ' '

You can see why I need help!!! :)
Thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,943
Messages
6,127,820
Members
449,409
Latest member
katiecolorado

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