please test if it helps Sub BlaBlaBla() 'siti Vi / jakarta, 2 mar 2011 Dim Dat As Range, r As Long, c As Integer Set Dat = Sheets(1).Cells(1).CurrentRegion For r = 1 To Dat.Rows.Count c = InStr(1, Dat(r, 1), " 12 $", vbTextCompare) - 1 Dat(r, 2) = Left(Dat(r, 1), c) Next r End Sub
assuming that your data is starts in A1 at sheet(1) / most left tab The result will be written in column B On Wed, Mar 2, 2011 at 12:39 AM, CAN <cdelano...@gmail.com> wrote: > I have a .CSV file that contains all the data in column A. Each row > has different information. > > I am looking for macro that will review the data on each row and > whenever find the number "12" it will delete it along with all the > information after. > > For example see data below > > 1 MF2-001 B Y MILAGROS ALVARADO 12 $140.00 01/01/11 $25.00 14 DAYS > 2 MF2-002 B Y OLIVER B. & INGRID Y. URQUIETA 12 $140.00 01/01/11 > $25.00 14 DAYS > 3 MF2-003 B Y LUCIA G. FERNANDEZ 12 $140.00 01/01/11 $25.00 14 DAYS > 4 MF2-004 B Y JOHNNY BARAKAT 12 $140.00 01/01/11 $25.00 14 DAYS > > The data on each row is only in column A. In row 1 I need a macro > that will delete all the words or caracters after the word "Alvarado". > > In row 2 to delete all the words after "Urquieta" > In row 3 to delete all the words after "Fernandez", etc, etc. > > In other words to identify in each colum "space+ 12" and delete > anything that begins with 12 but leaving intact everything before. > > After the macro runs, the data must look like this. > > 1 MF2-001 B Y MILAGROS ALVARADO > 2 MF2-002 B Y OLIVER B. & INGRID Y. URQUIETA > 3 MF2-003 B Y LUCIA G. FERNANDEZ > 4 MF2-004 B Y JOHNNY BARAKAT > > The macro needs to loop until the last row. > > I will appreciate any help with this. Thank you in advance. -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel