PDA

View Full Version : Solved: macro to import data from text file to excel worksheet



hunna
02-01-2012, 02:36 AM
Hello, if it's possible to import data from notepad file as shown below to excel worksheet

###FS: #m/z: 452.45772 #charge 4
###MaxRes:#m/z: 0.00000 #charge-128
###MS: 310/322/
###MSMS: 311/323/
BEGIN IONS
TITLE= Cmpd 3, +MSn(qCID 452.45773), 8.3 min
PEPMASS=452.457724 57901600
CHARGE=4+
988.377375 887529 1+
1429.599681 529223 1+
1468.611762 413207 1+
1486.622637 5422616 1+
1546.654642 449513 1+
1633.691009 2616784 1+
1693.722295 233800 1+
1746.773908 1124504 1+
END IONS

###FS: #m/z: 455.45775 #charge 4
###MaxRes:#m/z: 0.00000 #charge-128
###MS: 332/
###MSMS: 333/
BEGIN IONS
TITLE= Cmpd 4, +MSn(qCID 455.45776), 8.7 min
PEPMASS=455.457752 15566104
CHARGE=4+
1486.621979 1017876 1+
1498.622860 1611628 1+
1558.654479 751780 1+
1633.687634 438510 1+
1645.691839 1029980 1+
END IONS

###FS: #m/z: 441.44831 #charge 4
###MaxRes:#m/z: 0.00000 #charge-128
###MS: 350/
###MSMS: 351/
BEGIN IONS
TITLE= Cmpd 5, +MSn(qCID 441.44830), 9.2 min
PEPMASS=441.448313 15040184
CHARGE=4+
439.843652 1602845 1+
986.363048 1171237 1+
1484.607104 711710 1+
1502.617080 2936742 1+
1649.685047 1870409 1+
1762.768662 481024 1+
END IONS

In excel worksheet I want to keep only the red part (column A is m/z and D is charge number)

A B C D
471.9377 0 0 3
471.2413 1994913 1+
1043.611 869664 1+
1243.691 1882480 1+
1300.714 3368120 1+
1413.796 2822475 1+

784.0566 0 0 3
832.4409 316937 1+
2021.019 394193 1+
2333.134 291084 1+
2350.152 260149 1+

601.7732 0 0 4
646.3415 898599 1+
2404.067 365217 1+


I have a lot of data so I need macro to automate this work.

Any help would be appreciated. :bow:

wakdafak
02-01-2012, 02:45 AM
7336

please check the code attached :think:

mohanvijay
02-01-2012, 03:03 AM
Check Below thread

http://www.vbaexpress.com/forum/showthread.php?t=39830

I think they two threads are same

wakdafak
02-01-2012, 03:05 AM
@hunna

how come you post the thread exacly the same.. :banghead:

hunna
02-01-2012, 03:53 AM
@ wakdafak (http://www.vbaexpress.com/forum/member.php?u=43257)

Thank you very much for you kind help.

Those threads are not exactly the same. The difference is the patterns of data in attached files that I wanted to import to worksheet.

I am sorry that I used the same question because I thought that it's already easy to understand my problem.

hunna
02-01-2012, 04:08 AM
I am sorry I just saw that they are the same patterns in the post (but not in the attached files). :stars:

deeply truly sorry!!!! :banghead: