![]() |
Input filename at start of macro
I have a worksheet with data that needs to be copied to several different
workbooks. I have a macro that will copy the data correctly to one specific workbook. What I need is to start the macro so that it asks me the workbook filename. It then needs to be able to copy to that specific workbook (which will already have been opened). I don't know much VBA but am imagining that I need to name a variable with the filename that the user inputs, then use that variable as the reference in all of my copy and paste commands. Does this make any sense? If so, how do I program VBA to ask for a user-inputted filename? Thanks! -- Sara |
Input filename at start of macro
sFilename = Inputbox("Supplu filename")
If right(sFilename,4) < ".xls" Then sFilename = sFilename & ".xls" End If Set oWB = Wokbooks(sFilename) then use oWB in the code -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Sara" wrote in message ... I have a worksheet with data that needs to be copied to several different workbooks. I have a macro that will copy the data correctly to one specific workbook. What I need is to start the macro so that it asks me the workbook filename. It then needs to be able to copy to that specific workbook (which will already have been opened). I don't know much VBA but am imagining that I need to name a variable with the filename that the user inputs, then use that variable as the reference in all of my copy and paste commands. Does this make any sense? If so, how do I program VBA to ask for a user-inputted filename? Thanks! -- Sara |
All times are GMT +1. The time now is 03:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com