Solved

Excel source data lookup based on variable

Posted on 2012-03-15
4
193 Views
Last Modified: 2012-03-15
I hope somebody can help with this question.

I am trying to create a set of financial reports for a customer based upon data imported into Excel using an ODBC data query.  The data is imported into a worksheet called 'Source Data' and contains 12 columns, one for each financial period 1 through to 12.

The reporting worksheet, 'Report', uses a link, =ABS('Source Data'!$R$4) for period 1, =ABS('Source Data'!$S$4) for period 2, etc.  'Report' has a variable called 'Period' which will accept a user entered value between 1 and 12, corresponding to the financial period.

Is there a way of updating the link source to update the column $R, $S, etc. based upon the value of 'Period', rather than using a set of nested IF statements?  So if 'Period' = 1 then the link would be "=ABS('Source Data'!$R$4)", if 'Period' = 2 then the link would be "=ABS('Source Data'!$S$4)", and so on.  As the report has around 50 rows it would save a lot of typing and potential errors.
0
Comment
Question by:AztechMicros
  • 2
4 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 37727194
"=ABS('Source Data'!" & Cells(4, 17 + period).Address & ")"
0
 
LVL 41

Assisted Solution

by:dlmille
dlmille earned 150 total points
ID: 37727232
@ssaqibh - would INDIRECT be required here?

@AztechMicros - are you looking for macro code or a smart formula?

Dave
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 350 total points
ID: 37727262
Hi, Dave, I went by

has a variable called 'Period' which

thinking that it was for VBA but maybe variable means range name

So in that case it should be

=ABS(INDIRECT(ADDRESS(4,17+period,,,"Source Data")))
0
 

Author Closing Comment

by:AztechMicros
ID: 37728067
Absolutely bloody marvellous!!  Thanks guys.  Worked straight away with that solution, makes my reports a WHOLE lot easier.

I hope I have split the points fairly, and yes it was a smart formula I was using.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now