How would you refence 'ActiveSheet' instead of the actual sheet in the following section of code?

xcelnovice101

Active Member
Joined
Aug 24, 2012
Messages
368
Rich (BB code):
[M2].FormulaArray = "=MAX(IF('Historical Orders'!$B$2:$B$1048576='Form (2)'!M1,'Historical Orders'!$K$2:K1048576+1,1))"
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
try:
[M2].FormulaArray = "=MAX(IF('Historical Orders'!$B$2:$B$1048576='" & activesheet.Name & "'!M1,'Historical Orders'!$K$2:K1048576+1,1))"
 
Upvote 0
You are welcome. Just remember you a building a string to represent the formula so you can use all the functions to build the string.
 
Upvote 0
Perhaps you can just remove the sheet reference all toghether..
If the sheet you want to reference is the sheet that will contain the formula...then no sheet reference is required..

Code:
[M2].FormulaArray = "=MAX(IF('Historical Orders'!$B$2:$B$1048576=M1,'Historical Orders'!$K$2:K1048576+1,1))"
 
Upvote 0
I did not look at where the formula was being assigned and assumed the range that the formula is being assigned to could be on a sheet other than the active sheet.
 
Upvote 0
I'm taking the following assumption:
Given that there is no sheet specified in the code for where the formula is going, then by default it goes to whatever is the currently active sheet..
Rich (BB code):
[M2].FormulaArray = "...
So if the formula goes on the currently active sheet, and we want that cell reference to refer to the currently active sheet...
Then we don't need the sheet reference at all.
 
Upvote 0

Forum statistics

Threads
1,203,245
Messages
6,054,368
Members
444,720
Latest member
saathvik

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