I have a data base with a macro in it, What it does is it takes data from a region (and the states within the region) and puts it into an excel output file.
What I did was save the data base four times, each one with a macro specific to the four regions of the country. What I want to do is combine the four macros.
My problem is that each macro has to put data into different excel files, this wasn't a problem when I had four separate data bases, each with their own macro in each. Combining the 4 macros into the one data base and making sure each macro puts the data into the separate files is not working though, any suggestions?
This is the code I'm using that indicates the output file.
<code>
Sub insert_exhibits(source_range As String, output_range As String, source_worksheet As String, output_worksheet As String)
'Set xl = CreateObject("Excel.Application")
Source = ThisWorkbook.Name
file_path = ThisWorkbook.Path
Output_File = "Exhibits Midwest.xls"
'Workbooks.Open Filename:=Output_File
Visible = True
Workbooks(Output_File).Sheets(output_worksheet).Range(output_range) = _
Workbooks(Source).Sheets(source_worksheet).Range(source_range).Value
End Sub
<end code>
The output file of "Exhibits Midwest.xls" is only one of the four out put files,
the other are the Northeast, South and West.
If you have any suggestions they would be greatly appreciated, I'm kind of new to VBA still and I'm sure the answer is simple, I just simply don't know enough about VBA yet.
What I did was save the data base four times, each one with a macro specific to the four regions of the country. What I want to do is combine the four macros.
My problem is that each macro has to put data into different excel files, this wasn't a problem when I had four separate data bases, each with their own macro in each. Combining the 4 macros into the one data base and making sure each macro puts the data into the separate files is not working though, any suggestions?
This is the code I'm using that indicates the output file.
<code>
Sub insert_exhibits(source_range As String, output_range As String, source_worksheet As String, output_worksheet As String)
'Set xl = CreateObject("Excel.Application")
Source = ThisWorkbook.Name
file_path = ThisWorkbook.Path
Output_File = "Exhibits Midwest.xls"
'Workbooks.Open Filename:=Output_File
Visible = True
Workbooks(Output_File).Sheets(output_worksheet).Range(output_range) = _
Workbooks(Source).Sheets(source_worksheet).Range(source_range).Value
End Sub
<end code>
The output file of "Exhibits Midwest.xls" is only one of the four out put files,
the other are the Northeast, South and West.
If you have any suggestions they would be greatly appreciated, I'm kind of new to VBA still and I'm sure the answer is simple, I just simply don't know enough about VBA yet.