VBA - Linking to other named workbooks

gg452

New Member
Joined
Jun 17, 2013
Messages
6
Dear All,

I hope this wonderful forum could help please. I gain alot of experience and knowledge from people on here so firstly a thank you for that.

I've looked on the forum but am unable to find the answer the to query below (I may not be wording it correctly).

The code I'm trying to write is basically a cycle code that creates standard links to another file that is named in the macro - like so.

Code:
Sub LoopThroughSheets()


'Set the results file
Dim rwb As Workbook
Set rwb = Workbooks("Actuals.xlsx")


'Set the reference (current) workbook
Dim PMWB As Workbook
Set PMWB = Workbooks("Forecast.xlsm")


'Set the column of the file - plus 1 each month
Dim mycolumn As Integer
mycolumn = 5




    Dim Sheets As Variant
    Dim Sheet As Variant


    Sheets = Array("S1", "S2", "S3")


    For Each Sheet In Sheets
        
    'This needs to change per sheet
    Dim myrow As Integer
    myrow = 30
            
            
        Cells(30, mycolumn).Select
        ActiveCell.Formula = "='[" & rwb & "]Actual'!C" & myrow
        Cells(64, mycolumn).Select
        ActiveCell.Formula = "='[" & rwb & "]Actual'!C" & myrow
        Cells(113, mycolumn).Select
        ActiveCell.Formula = "='[" & rwb & "]Actual'!C" & myrow
        
    Next Sheet


End Sub

Any and all help would be greatly appreciated.

Thank you in advance

GG452
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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