varArray = Split("C:\New folder\text.xlsx|D:\New Folder\text1.xlsx|E:\New folder\text2.xlsx", "|") Set objExcel = CreateObject("Excel.Application") For lng = LBound(varArray) To UBound(varArray) Set objWorkbook = objExcel.Workbooks.Open(varArray(lng)) For Each wks In objWorkbook.Worksheets wks.Range("A2", wks.UsedRange.SpecialCells(11)(2)).EntireRow.Delete Next objWorkbook.Save '"C:\Users\Sam\Desktop\DelAllRowsExcelA1.xls" objWorkbook.Close Next objExcel.Application.Quit WScript.Echo "Finished." WScript.Quit
Regards, Sam Mathai Chacko On Fri, Jan 27, 2012 at 7:43 AM, yogananda muthaiah < yogananda.mutha...@gmail.com> wrote: > Dear All, > > Did anyone try this .. > > Regards > Yogananda > > ---------- Forwarded message ---------- > From: yogananda muthaiah <yogananda.mutha...@gmail.com> > Date: Wed, Jan 25, 2012 at 10:06 PM > Subject: VB Script - looping of files > To: excel-macros@googlegroups.com > > > > Dear All > > I have 3 excel path mentioned below which needs to be looped for below VB > script. > > > > Path : C:\New folder\text.xlsx > D:\New Folder\text1.xlsx > E:\New folder\text2.xlsx > > > > --- Below code working sucessfull for single excel ----------------------- > > Set objExcel = CreateObject("Excel.Application") > Set objWorkbook = objExcel.Workbooks.Open("*C:\**Users\Sam\Desktop\** > DelAllRowsExcelA1.xls*") > for each wks in objworkbook.worksheets > wks.Range("A2", wks.UsedRange.SpecialCells(11)(2)).EntireRow.Delete > next > objWorkbook.Save '"*C:\Users\Sam\Desktop\****DelAllRowsExcelA1.xls*" > objWorkbook.Close > objExcel.Application.Quit > WScript.Echo "Finished." > WScript.Quit > > > > > Regards > Yogananda Muthaiah > Ph : 973 123 7267 > > > > > -- > > > > Regards > Yogananda Muthaiah > Ph : 973 123 7267 > > -- > FORUM RULES (986+ members already BANNED for violation) > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > > 2) Don't post a question in the thread of another member. > > 3) Don't post questions regarding breaking or bypassing any security > measure. > > 4) Acknowledge the responses you receive, good or bad. > > 5) Cross-promotion of, or links to, forums competitive to this forum in > signatures are prohibited. > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > owners and members are not responsible for any loss. > > > ------------------------------------------------------------------------------------------------------ > To post to this group, send email to excel-macros@googlegroups.com > -- Sam Mathai Chacko -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com