I am trying to copy a named range from an external workbook to replace the named range in my active workbook.
I am getting a type mismatch error which I figure maybe because I did not call my source a range.
Could you please help me out with my syntax?
Code below:
Sub ImportLogInfo()
Dim wkbCrntWorkBook As Workbook
Dim wkbSourceBook As Workbook
Dim rngSourceRange As Range
Dim rngDestination As Range
Set wkbCrntWorkBook = ActiveWorkbook
Set wkbSourceBook = Workbooks.Open(Filename:="C:\Users\Documents\Proposal Log Feeder\Log Feeder A.xlsb", ReadOnly:=True)
Set rngSourceRange = wkbSourceBook.Sheets("Log").Range("DBrange")
wkbCrntWorkBook.Activate
Set rngDestination = wkbCrntWorkBook.Sheets("Log").Range("DBrange")
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit
wkbSourceBook.Close False
End Sub
Ranges have the same name, DBrange.
If possible, I would also only like copy columns from A:AD.
If this is not possible, that's fine.
Thanks in advance.
Set rngDestination = wkbCrntWorkbook.Sheets("Log").Range("DBrange")- RemimsoFileDialogOpenand just have the a button click open the external file, get the information needed and close the file without user input. See my edit. - Remi