S
Steve
Hi,
I have the following macro that will shell out and open another
spreadsheet to bring some data back into my workbook. Somehow, I need
this macro to close that externally referenced file (without saving)
once it opens it, manipulates some data and copies it to bring back
into my workbook. Everything works now except the closing part.
The second part of my problem is that one of the sheets in this
workbook is protected because of a macro button I have on that sheet.
It's protected without a password. I need to get the protection to
temporarily be turned off to do some things and then turn itself back
on again.
Any help would certainly be appreciated...
Regards,
Steve
Sub Macro1()
' Macro1 Macro
' Macro recorded 6/5/2007 by Stephen Shockley
'
'
Application.ScreenUpdating = False
Dim myvalue As Variant
myvalue = Application.GetOpenFilename
Workbooks.Open Filename:=myvalue
Application.DisplayAlerts = False
' DOING SOME THINGS TO THE EXTERNALLY REFERENCED FILE
Cells.Select
Selection.Copy
Application.DisplayAlerts = True
Windows("Simplify Where-Used Report.xls"). _
Activate
Sheets("Where-Used Imported").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Filter Out Blanks 1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="X"
Range("B1:E40001").Select
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Sheets("Filter Out Blanks 2").Select
ActiveWindow.SmallScroll Down:=-3
Range("C1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="<>"
Range("A2:F2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:F2501").Select
Selection.Copy
Sheets("Simplified Where-Used").Select
' NEED TO UNPROTECT THE "Simplified Where-Used" NAMED SHEET HERE
Selection.PasteSpecial Paste:=xlPasteColumnWidths,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Columns("C
").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("A1").Select
' NEED TO RE-PROTECT THE "Simplified Where-Used" NAMED SHEET
HERE
Range("A1").Select
End Sub
I have the following macro that will shell out and open another
spreadsheet to bring some data back into my workbook. Somehow, I need
this macro to close that externally referenced file (without saving)
once it opens it, manipulates some data and copies it to bring back
into my workbook. Everything works now except the closing part.
The second part of my problem is that one of the sheets in this
workbook is protected because of a macro button I have on that sheet.
It's protected without a password. I need to get the protection to
temporarily be turned off to do some things and then turn itself back
on again.
Any help would certainly be appreciated...
Regards,
Steve
Sub Macro1()
' Macro1 Macro
' Macro recorded 6/5/2007 by Stephen Shockley
'
'
Application.ScreenUpdating = False
Dim myvalue As Variant
myvalue = Application.GetOpenFilename
Workbooks.Open Filename:=myvalue
Application.DisplayAlerts = False
' DOING SOME THINGS TO THE EXTERNALLY REFERENCED FILE
Cells.Select
Selection.Copy
Application.DisplayAlerts = True
Windows("Simplify Where-Used Report.xls"). _
Activate
Sheets("Where-Used Imported").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Filter Out Blanks 1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="X"
Range("B1:E40001").Select
Selection.Copy
Application.CutCopyMode = False
Selection.Copy
Sheets("Filter Out Blanks 2").Select
ActiveWindow.SmallScroll Down:=-3
Range("C1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="<>"
Range("A2:F2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:F2501").Select
Selection.Copy
Sheets("Simplified Where-Used").Select
' NEED TO UNPROTECT THE "Simplified Where-Used" NAMED SHEET HERE
Selection.PasteSpecial Paste:=xlPasteColumnWidths,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Columns("C

Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("A1").Select
' NEED TO RE-PROTECT THE "Simplified Where-Used" NAMED SHEET
HERE
Range("A1").Select
End Sub