![]() |
How to use .GetOpenFilename in For loop?
I need the user to select his file, and am using the
..GetOpenFilename format. However, I need to use the following: For each c in workbooks("filename"). ... What to do about the reqd quotation marks around the filename, and what to do about the "\" path marks which excel does not recognise? Milind --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003 |
How to use .GetOpenFilename in For loop?
Milind,
Are you trying to lop through the sheets in the workbook you have just opened? If so, you don't need a filename, you can use ActiveWorkbook, like this Dim fileToOpen fileToOpen = Application _ .GetOpenFilename("Microsoft Excel Files (*.xls), *.xls") If fileToOpen < False Then For Each c In ActiveWorkbook 'DO SOMETHING Next End If -- HTH Bob Phillips "Milind" wrote in message ... I need the user to select his file, and am using the .GetOpenFilename format. However, I need to use the following: For each c in workbooks("filename"). ... What to do about the reqd quotation marks around the filename, and what to do about the "\" path marks which excel does not recognise? Milind --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003 |
How to use .GetOpenFilename in For loop?
fname = GetOpenFilename()
sBkName = dir(fname) workbooks.open fname for each c in Workbooks(sBkName).Worksheets or set a reference to it when it is opened. Dim wkbk as Workbook fname = GetOpenFilename() set wkbk = workbooks.open( fname) for each c in wkbk.Worksheets Regards, Tom Ogilvy "Milind" wrote in message ... I need the user to select his file, and am using the .GetOpenFilename format. However, I need to use the following: For each c in workbooks("filename"). ... What to do about the reqd quotation marks around the filename, and what to do about the "\" path marks which excel does not recognise? Milind --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003 |
All times are GMT +1. The time now is 08:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com