JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
I'm sure this has been asked before but I can't seem to find the answer in the search function on this site or Google; I'm probably not asking correctly.
I have the following code:
Range("CLOSING_NAV") is local to the workbook that is opened.
I would rather have some code along the lines of:
I'm sure this has been asked before but I can't seem to find the answer in the search function on this site or Google; I'm probably not asking correctly.
I have the following code:
Rich (BB code):
Sub Step2_ImportEFHoldings()
Dim archiveworkbook As Workbook
Dim SecurityNames As Range, SecurityHoldings As Range
Set currentworkbook = ActiveWorkbook
Application.DisplayAlerts = False
msg = "Please enter a valid file date"
With Sheets("MS File")
.Range("FileDate").Select
If Len(.Range("FileDate")) < 10 Then
MsgBox msg, vbExclamation, "Invalid date"
Exit Sub
End If
End With
On Error GoTo WorkbookError
Workbooks.Open Filename:=Range("FileName"), UpdateLinks:=True, ReadOnly:=True
Set archiveworkbook = ActiveWorkbook
On Error GoTo 0
Range("CLOSING_NAV").Copy
currentworkbook.Activate
Range("FileNAV").PasteSpecial Paste:=xlValues
archiveworkbook.Close savechanges:=False
Exit Sub
WorkbookError:
msg = "File not found, please check"
MsgBox msg, vbExclamation, "File not found"
End Sub
I would rather have some code along the lines of:
Rich (BB code):
currentworkbook.Range("FileNAV") = archiveworkbook.Range("CLOSING_NAV") but when I try this (as well as workbook.Sheets("sheet name").Range("FileNAV") = etc..) I keep getting an error message of invalid range or object
Can someone explain how I should be writing this?
Thanks,
Jack