Hi,
I am new to VBA and I am experimenting with Excel Macros. I want to copy a cell value from another sheet to my sheet.
The sheet Random.xlsx has the value that I need to copy to my current sheet. I have written the following code:
Private Sub OptionButton1_Click()
Dim wb1 As Workbook
Set wb1 = Workbooks("Random.xlsx")
Workbooks.Open Filename:="D:\Excel\Random.xlsx"
Range("E5").Value = wb1.Sheets("Sheet1").Range("B2").Value
End Sub
But I am getting the runtime error 9 - subscript out of range.
Now this issue has been handled on the forum before but I still can't make head or tail of it.
Any help would be highly appreciated.
Regards,
Kush
Bookmarks