Hi I hope you can help me. I have made a report that analyses information that extracts from a company template. I have made a macro that copies specify sheet from the template to a hidden sheet on the Report file.
The thing is that the company template could have different names even if the information or the format in it remains the same.
So I need that my macro asks me for the name of the template file and then copies the information from that specified file on to my report.
This is the code I have.
Template will be the name of the variable and total mx 08.xls is the name that I want to change acording to the input name.
Sub Analisis_Bud()
'
' Analisis_bud Macro
' Macro recorded 2/15/2008 for templates version 2008
'
'On Error GoTo Erreur1
Current_File1 = Worksheets("Inst").Cells(21, 2).Value
Windows(Current_File1).Activate
Worksheets("Inst").Select
cont = MsgBox("Is the template file open?", vbYesNo)
If cont = vbNo Then
cont = MsgBox("open the template and try again")
Exit Sub
End If
CurrentFile = Application.InputBox("Input your template name ending with .xls")
If CurrentFile = False Then
Template = MsgBox("Please have your template open and input the name correcly!", vbOKOnly)
If Template = vbOK Then
Exit Sub
End If
End If
'Turn off screen flickering
Application.ScreenUpdating = False
Sheets("Operating Income-Budget").Visible = True
Windows("total mx 08.xls").Activate <- - This is the name of the template that I want it to be variable according to the previous input name
Cells.Select
Selection.AutoFilter
Selection.EntireColumn.Hidden = False
Selection.EntireRow.Hidden = False
Cells.Select
Selection.Copy
Windows("Analisis by PL.xls").Activate
Sheets("Operating Income-Budget").Activate
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Operating Income-Budget").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("inst").Activate
End Sub
MHT