Kahlan1177
New Member
- Joined
- Oct 4, 2018
- Messages
- 6
Hi,
So i am working on a macro that will allow me to open a window in workbook 1 to find an excel report file and then format that report. Once the format is complete it then copies and pastes to workbook 1 to the specified tab so that the original file is not touched or modified. I have 3 reports to do in this fashion.
This is what i have so far, but it keeps bugging when it goes to format, i only attached the main routine and one of the sub routines. Can anyone help me see my mistake?
So i am working on a macro that will allow me to open a window in workbook 1 to find an excel report file and then format that report. Once the format is complete it then copies and pastes to workbook 1 to the specified tab so that the original file is not touched or modified. I have 3 reports to do in this fashion.
This is what i have so far, but it keeps bugging when it goes to format, i only attached the main routine and one of the sub routines. Can anyone help me see my mistake?
Code:
Public Sub RiskOpen_Workbook_FileDialog()
'
' RiskOpen_Workbook_FileDialog Marco
' open file window to choose file
'
'
Dim fd As FileDialog
Dim lngPathLen As Long
Dim strPath As String, strfile As String, strTemp As String
strTemp = ""
Dim strfilepath as String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.ButtonName = "Select"
.InitialView = msoFileDialogViewDetails
.Title = "Select File To Update"
.InitialFileName = "\\Reports\Privacy & Reputational Risk Audit"
With .Filters
.Clear
.Add "Excel Workbooks", "*.xls; *.xlsx"
End With
.FilterIndex = 1
If .Show = -1 Then
strTemp = .SelectedItems(1)
End If
Set fd = Nothing
End With
If strTemp <> "" Then
lngPathLen = InStrRev(strTemp, "")
strPath = Left(strTemp, lngPathLen)
strfile = Right(strTemp, Len(strTemp) - lngPathLen)
Debug.Print strPath
strfilepath = strPath & strfile
If Left(strfile, 6) = "MonAdj" Then
Call MonAdj
End If
If Left(strfile, 5) = "Award" Then
Call Award
End If
If Left(strfile, 5) = "Other" Then
Call Other
End If
End If
End Sub
Public strfilepath As String
Sub MonAdj()
'
' MonAdj Macro
'
Workbooks.Open Filename:=strfilepath
Application.Width = 1011
Application.Height = 757.5
Cells.Select
Cells.EntireColumn.AutoFit
Selection.ColumnWidth = 8.13
Rows("1:4").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-18
Columns("B:B").ColumnWidth = 8
Columns("B:B").EntireColumn.AutoFit
Columns("C:C").EntireColumn.AutoFit
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Columns("G:G").EntireColumn.AutoFit
Cells.Select
Selection.Copy
Windows("MACRO Sampler .xlsm").Activate
Sheets("Mon Adj").Select
Cells.Select
ActiveSheet.Paste
End Sub
Last edited by a moderator: