link in excel macro

M

matt

I have an excel macro that needs to get data from a different worksheet. I
can add a link successfully in in my workbook that grabs data from another
workbook, but I dont know the context in the vb editor

can anyone help me??
 
B

Barb Reinhardt

This should get you started:

Sub test()
Dim myWS As Worksheet
Dim aWS As Worksheet

Set aWS = ActiveSheet

Set myWS = Nothing
On Error Resume Next
Set myWS = Worksheets("Sheet2")
On Error GoTo 0
If Not myWS Is Nothing Then
'Reference cells in myWS
aWS.Cells(1, 1) = myWS.Cells(1, 1) '<~~~change this as needed
End If


End Sub

HTH,
Barb Reinhardt
 
M

matt

Thanks Barb - you're the greatest!!! Im still new at this and you just got me
through this!
 
Top