SQL Parameter - Same cell, different sheet

griffj

Board Regular
Joined
May 29, 2015
Messages
56
Hi All,

I have setup a datasource in Excel and I am using a Parameter to pass the value from Excel to the SQL database and return the results, this all works fine.

What I would like to do is have the parameter set to the same cell (in my instance this is H14) but the worksheet changes. I have 14 worksheets, and on each of them cell H14 contains the information I need to query the SQL db,

What I want to achieve is that if I am working on 'Worksheet 2' then the parameter being passed to SQL would be 'Worksheet 2!$H$14', but if I was to change and work on 'Worksheet 10' the parameter would look at 'Worksheet 10!$H$14'.

Is this possible? I have been looking into the ActiveWorkbook function, but with no joy. Any help would be great.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,216,434
Messages
6,130,596
Members
449,584
Latest member
c_clark

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