Workbook referencing

CB76

New Member
Joined
May 11, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi,
Found this code in another thread.
How do I reference another workbook containing "Sheet1" i below code that i would like to copy the data to?


Sub ExportData()
Dim Cl As Range
Dim Dic As Object

Set Dic = CreateObject("scripting.dictionary")
With Sheets("Sheet2")
For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
Dic(Cl.Value) = Cl.Offset(, 1).Value
Next Cl
End With
With Sheets("Sheet1")
For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
If Dic.exists(Cl.Value) Then Cl.Offset(, 5).Value = Dic(Cl.Value)
Next Cl
End With
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi
If the other book is open
just inset this line of code
VBA Code:
 Windows("test - Copy.xlsm").Activate'<< Name of your other workbook to be changed
Befor
VBA Code:
With Sheets("Sheet1")
 
Upvote 0
Can it be done with the workbook closed? And both workbooks are stored in Sharepoint.
 
Upvote 0
Ideas anyone?

How to use the code above but reference the target file on Sharpoint ?
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top