T
TK
Why can't I get this to work? NewFN always equals the file I selected but
wbExt always equals "nothing" and the routine crashes. I can't figure out
what I'm doing wrong.
Thanks in advance,
Todd
Private Sub CommandButton1_Click()
NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),
*.xls", Title:="Select a file")
If NewFN = False Then
MsgBox "No File Was Selected"
Else
Workbooks.Open FileName:=NewFN
Dim wbExt As Workbook
Set wbExt = NewFN
wbExt.Worksheets("Sheet1").Range("C4").Copy
Application.CutCopyMode = False
wbExt.Close savechanges:=False
Set wbExt = Nothing
End If
End Sub
wbExt always equals "nothing" and the routine crashes. I can't figure out
what I'm doing wrong.
Thanks in advance,
Todd
Private Sub CommandButton1_Click()
NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),
*.xls", Title:="Select a file")
If NewFN = False Then
MsgBox "No File Was Selected"
Else
Workbooks.Open FileName:=NewFN
Dim wbExt As Workbook
Set wbExt = NewFN
wbExt.Worksheets("Sheet1").Range("C4").Copy
Application.CutCopyMode = False
wbExt.Close savechanges:=False
Set wbExt = Nothing
End If
End Sub