Solved

Excel source data lookup based on variable

Posted on 2012-03-15
4
200 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:Steve Brown
  • 2
4 Comments
 
LVL 43

Expert Comment

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

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:Steve Brown
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

726 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