Hi,
I am struggling to do something really simple:
Adding a Macro to my active workbook which opens another workbook (located in the same folder), copy all the values from one sheet and pasting it into my active worksheet.
Here is my code:
Sub Button1_Click()
Dim filename As String
Dim nb_csp As String
Dim c As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
nb_csp = Range("'5- AOCS'!K12")
filename = "" & nb_csp & "_" & "BOM.xls"
Set c = Workbooks.Open(ActiveWorkbook.Path & filename)
Set ws1 = c.Sheets("ModuleInfoDetail")
Set ws2 = ActiveSheet
ws1.UsedRange.Copy ws2.Cells("A5")
End Sub
I got an error: Run-time error '5':
Invalid procedure call or argument
Could somebody help me?
thank you very much in advance
I am struggling to do something really simple:
Adding a Macro to my active workbook which opens another workbook (located in the same folder), copy all the values from one sheet and pasting it into my active worksheet.
Here is my code:
Sub Button1_Click()
Dim filename As String
Dim nb_csp As String
Dim c As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
nb_csp = Range("'5- AOCS'!K12")
filename = "" & nb_csp & "_" & "BOM.xls"
Set c = Workbooks.Open(ActiveWorkbook.Path & filename)
Set ws1 = c.Sheets("ModuleInfoDetail")
Set ws2 = ActiveSheet
ws1.UsedRange.Copy ws2.Cells("A5")
End Sub
I got an error: Run-time error '5':
Invalid procedure call or argument
Could somebody help me?
thank you very much in advance