Help with writing a macro

  • Thread starter Thread starter SHII
  • Start date Start date
S

SHII

All I want to do is prompt user to select month 1 - 12 and file name
then VBA will open these files. Here is location of the files


"D:\ccview\2_wlcbf\wbs\W Production\Business Validation Rollback
Results\Monthly\Month 18\Month 18 Reports"

What changes is Month 18\Month 18 Reports. If user selects month 12 I
want this vba get the file from Month 12\Month 12 Reports. Again user
will be prompted to enter file name. If user selects file name Prod
Month 12 Report 12MF then vba will open

"D:\ccview\2_wlcbf\wbs\W Production\Business Validation Rollback
Results\Monthly\Month 18\Month 18 Reports\ Prod Month 12 Report
12MF.xls

Thanks in advance for your help.
 
The last paragraph should read:

What changes is Month 18\Month 18 Reports. If user selects month 12, I
want the code to open:

"D:\ccview\2_wlcbf\wbs\W Production\Business Validation Rollback
Results\Monthly\Month 12\Month 12 Reports\

And the the user will be prompted to enter file name:

Prod Month 12 Report 12MF.xls


Then the code will pass this information onto the rest of the code
where I have vlookups, cut and paste etc.

Then I want the macro close all the open files except workbookA. I do
not want to be prompted to save changes I made to the files I opened
like

D:\ccview\2_wlcbf\wbs\W Production\Business Validation Rollback
Results\Monthly\Month 12\Month 12 Reports\Prod Month 12 Report 12MF.xls



Thanks
Shukri
 
How about letting the user choose the file

Chdrive "D"
ChDir "D:\ccview\2_wlcbf\wbs\W Production\" & _
"Business Validation Rollback Results\Monthly"
fName = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),*.xls")
msgbox fName
 
I have found this vba:

Dim j As Integer
j = InputBox("select any number between 1 and 12")
Workbooks.Open Filename:= _
"c:\Documents and Settings\Owner\Desktop\month" & " " & j &
"\premium.xls"


This will open prompt user to select a month and then it goes into
Month (x selected by user) and then opens premium file. Now I want to
open 3 other files and I cannot seem to add the above code. Can anyone
please share how I can add, say, Discount.xls file to the above code. I
tried this way (I just came up with it) but it did not work, of course.

"c:\Documents and Settings\Owner\Desktop\month" & " " & j &
"\premium.xls; Discount.xls"

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top