Dynamic Ranges (without range address unavailable) inside a Formula

predzer

New Member
Joined
Jun 21, 2018
Messages
20
Hey Guys!

I immensely need your help for the below scenario.

I am trying to find a way to address range in a formula. The problem is that, the range is created dynamically. Please refer below image further.
attachment.php


Here I have 2 tables say Table 1 & Table 2, these tables are snippets of my actual table which has 50 columns & 40 Rows.

Table 1 is generated from a pivot table, and it is dynamic so I wont be having idea of its address (except cell A1 where table 1 starts always)

so Have used the below codes to set range of table 2

Code:
[COLOR=#333333]Set table2top = Range("A1").End(xlToRight).Offset(0, 1) 
Set table2bot = Range("A1").End(xlToRight).End(xlDown).Offset(0, 1)
[/COLOR]

Now i have to enter formula =AVERAGEIF($A$1:$I$1,K$1,$A2:$I2) in cell K2 and use autofill for rest of table 2.


I need your help to Replace cell range ($A$1:$I$1,K$1,$A2:$I2) to 'something' as i wont be knowing cell range except starting cell A1.


P.S. I tried naming date row. so i can replace $A$1:$I$1 with a name, but could not figure out for the next part of formula.

I just started using VBA to build a model & Im almost halfway through my model but stuck at this point
banghead.gif
please help me out
pray2.gif


(P.S. Also posted on
http://www.vbaexpress.com/forum/sho...nges-(without-range-address)-inside-a-Formula ​)
 
Which of these 2 statements is true? :confused:
The code I supplied can be made dynamic, but I need hard facts to do it.

I will be knowing the column headers. (Date Row) [I figured it out later to ease coding]

So, I can set boundaries of table 2 now. What i need is a formula to place in cell K2 and auto fill for entire table.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
If you need the formula to populate the entire table, then the macro has to now how any columns.
How will that be determined?
Can you please answer the above?
 
Upvote 0
If you need the formula to populate the entire table, then the macro has to now how any columns.
How will that be determined?

I will be knowing the column header range of table 2, since i am using table 1 header (date row) to remove duplicates.

Then i can use .column to determine the column number of 1st and last column of the table. The bottom of table can determined using offset function from 1st table, something like,

Code:
Range("A1").End(xlToRight).End(xlDown).Offset(0, 2)
 
Upvote 0
So both tables will have exactly the same number of columns, is that right?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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