How to automatically change the arguments of a formula in a range of cells (all of them in different sheets but in the same position)

Sorin Toma

New Member
Joined
Oct 29, 2022
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I have an workbook with a large number of sheets. One of them (named "Source") is like a "data source sheet" .The other sheets (named from 01 to 99) use some values from "Source" in simple formulas .
My problem is that I need to use same formula but with different arguments in each sheet ( for example: in sheet "01", cell A1= 'Source'!B1" and in sheet "02", same cell A1= 'Source'!B2" and so on) and I'm looking for a solution to to this automatically.
Could someone give me a hint (a formula or a macro) to avoid do this manually?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
One non-advisable approach will be:
Excel Formula:
=INDIRECT("'Source'!B"&INT(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)))
 
Upvote 0
Welcome to the MrExcel board!

Does this do what you want?

VBA Code:
Sub InsertFormulas()
  Dim i As Long
  
  For i = 1 To 99
    Sheets(Format(i, "00")).Range("A1").Formula = "=Source!B" & i
  Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

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