Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 424 - Object required 1

Status
Not open for further replies.

kalalala

Programmer
Sep 21, 2005
3
GB
Hello

I am getting the Runtime 424 error with the code below. I am a newbie and have looked at help but cannot understand how I can modify the code below to give me what I wana do.

Purpose of the code:

User selects a file->Open the file->copy over A10 to A10 of the source file

Thanks in advance



Sub test()

Dim file_open As Variant

file_open = Application.GetOpenFilename("Excel Files (*.xls), *.xls")

Workbooks.Open Filename:=file_open

' open the source workbook, read only
With ThisWorkbook.Worksheets("Sheet1")
' read data from the source workbook
.Range("A10").Formula = file_open.Worksheets("PM").Range("A10").Formula


End With
file_open.Close False ' close the source workbook without saving any changes
Set file_open = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating
End Sub
 
Sub test()
Dim file_open As Variant
Dim WB As Workbook
file_open = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
Set WB = Workbooks.Open Filename:=file_open
With ThisWorkbook.Worksheets("Sheet1")
' read data from the source workbook
.Range("A10").Formula = WB.Worksheets("PM").Range("A10").Formula
End With
WB.Close False ' close the source workbook without saving any changes
Set WB = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
compile error - syntax error on this line:

Set WB = Workbooks.Open Filename:=file_open

??
 
OOps, sorry for the typo:
Set WB = Workbooks.Open(Filename:=file_open)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top