Good morning helpful peeps! I have some code that has all of a sudden stopped working. It was working, but has since stopped. All it does now is lets me select the import workbook and then asks me if I want to save the current workbook. Nothing else happens. Both workbooks are password protected and need to unlock to allow the import, then lock again after. Help!
VBA Code:
Public Sub subImportData()
Dim AutoSv As Boolean
Dim fd As Office.FileDialog
Dim strFile As String
Dim WbThisWorkbook As Workbook
Dim WbImportFrom As Workbook
ActiveSheet.Unprotect Password:="232323"
ActiveWorkbook.Save
Application.ScreenUpdating = False
Set WbThisWorkbook = ThisWorkbook
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.Filters.Add "Excel Files", "*.xls?", 1
.Title = "Choose an Excel file"
.AllowMultiSelect = False
.InitialFileName = ActiveWorkbook.Path
If .Show = True Then
strFile = .SelectedItems(1)
End If
End With
If strFile = "" Then
Application.ScreenUpdating = True
Exit Sub
End If
Workbooks.Open strFile, ReadOnly:=True
Set WbImportFrom = ActiveWorkbook
WbThisWorkbook.Sheets("Sheet1").Range("R6").Value = WbImportFrom.Sheets("Sheet1").Range("C2").Value
WbThisWorkbook.Sheets("Sheet1").Range("F23").Value = WbImportFrom.Sheets("Sheet1").Range("C2").Value
WbThisWorkbook.Sheets("Sheet1").Range("F42").Value = WbImportFrom.Sheets("Sheet1").Range("C2").Value
WbThisWorkbook.Sheets("Sheet1").Range("F56").Value = WbImportFrom.Sheets("Sheet1").Range("C2").Value
WbThisWorkbook.Sheets("Sheet1").Range("F74").Value = WbImportFrom.Sheets("Sheet1").Range("C2").Value
WbThisWorkbook.Sheets("Sheet1").Range("H8").Value = WbImportFrom.Sheets("Sheet1").Range("C1").Value
WbThisWorkbook.Sheets("Sheet1").Range("F26").Value = WbImportFrom.Sheets("Hidden").Range("C7").Value
WbThisWorkbook.Sheets("Sheet1").Range("F27").Value = WbImportFrom.Sheets("Hidden").Range("C8").Value
WbThisWorkbook.Sheets("Sheet1").Range("F28").Value = WbImportFrom.Sheets("Hidden").Range("C9").Value
WbThisWorkbook.Sheets("Hidden").Range("A2").Value = WbImportFrom.Sheets("Hidden").Range("D23").Value
WbThisWorkbook.Sheets("Sheet1").Range("F45").Value = WbImportFrom.Sheets("Hidden").Range("C11").Value
WbThisWorkbook.Sheets("Sheet1").Range("F46").Value = WbImportFrom.Sheets("Hidden").Range("C12").Value
WbThisWorkbook.Sheets("Sheet1").Range("F47").Value = WbImportFrom.Sheets("Hidden").Range("C13").Value
WbThisWorkbook.Sheets("Hidden").Range("A5").Value = WbImportFrom.Sheets("Hidden").Range("D24").Value
WbThisWorkbook.Sheets("Sheet1").Range("F59").Value = WbImportFrom.Sheets("Hidden").Range("C15").Value
WbThisWorkbook.Sheets("Sheet1").Range("F60").Value = WbImportFrom.Sheets("Hidden").Range("C16").Value
WbThisWorkbook.Sheets("Sheet1").Range("F61").Value = WbImportFrom.Sheets("Hidden").Range("C17").Value
WbThisWorkbook.Sheets("Hidden").Range("A8").Value = WbImportFrom.Sheets("Hidden").Range("D25").Value
WbThisWorkbook.Sheets("Sheet1").Range("F77").Value = WbImportFrom.Sheets("Hidden").Range("C19").Value
WbThisWorkbook.Sheets("Sheet1").Range("F78").Value = WbImportFrom.Sheets("Hidden").Range("C20").Value
WbThisWorkbook.Sheets("Sheet1").Range("F79").Value = WbImportFrom.Sheets("Hidden").Range("C21").Value
WbThisWorkbook.Sheets("Hidden").Range("A11").Value = WbImportFrom.Sheets("Hidden").Range("D26").Value
WbThisWorkbook.Sheets("Hidden").Range("C15").Value = WbImportFrom.Sheets("Sheet1").Range("I24").Value
WbThisWorkbook.Sheets("Hidden").Range("C16").Value = WbImportFrom.Sheets("Sheet1").Range("I25").Value
WbThisWorkbook.Sheets("Hidden").Range("C17").Value = WbImportFrom.Sheets("Sheet1").Range("I26").Value
WbThisWorkbook.Sheets("Hidden").Range("C18").Value = WbImportFrom.Sheets("Sheet1").Range("I27").Value
WbImportFrom.Close
Application.ScreenUpdating = False
ActiveSheet.Protect Password:="232323"
End Sub