Solved

How do I copy a worksheet name reference with embedded date and have date increment?

Posted on 2011-03-11
12
232 Views
Last Modified: 2012-05-11
Hello Experts.  I need your help again.

I have this formula in cell A1 and I want to copy it down for each day of the month:
=SUBTOTAL(9,'Z:\Production Reports\[PR 01-2011.xls]11-01-01'!G$11:G$600)

Cell A2 should look like this:
=SUBTOTAL(9,'Z:\Production Reports\[PR 01-2011.xls]11-01-02'!G$11:G$600)

My source workbook name is:  PR 01-2011.xls
Each worksheet name represents a date, eg.:  11-01-02

You guys are so good at knowing how to save time/effort by writing formulas that can be copied.  Can you help me with this one?  

Thanks,
Gary
0
Comment
Question by:garyrobbins
  • 6
  • 4
12 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 35110032
Is this what you want?

Sub Sample()
    Dim LastRow As Long
    Dim strFormula As String
    
    '~~> To get the lastrow. Amend as applicable
    LastRow = Sheets("Sheet1").Range("B" & Rows.Count).End(xlUp).Row
    
    For i = 2 To LastRow
        '=SUBTOTAL(9,'Z:\Production Reports\[PR 01-2011.xls]11-01-01'!G$11:G$600)
        strFormula = "=SUBTOTAL(9,'Z:\Production Reports\[PR 01-2011.xls]11-01-" & _
        Format(i - 1, "00") & "'!G$11:G$600)"
        
        Sheets("Sheet1").Range("A" & i).Formula = strFormula
    Next
End Sub

Open in new window


Sid
0
 

Author Comment

by:garyrobbins
ID: 35111194
I'm not very comfortable yet with VBA.  Is there a way I can do this with the formula?

Gary
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35113720
UNTESTED

Yes there is. Insert a new column in B and type the following

In cell B1
1
In cell B2
2
In cell B3
3
and so on...

Type this formula in A1

=SUBTOTAL(9,INDIRECT("'Z:\Production Reports\[PR 01-2011.xls]11-01-"&TEXT(B1,"00")&"'!G$11:G$600"))

AND then pull the formula down.

Sid
0
 
LVL 6

Expert Comment

by:Eric Zwiekhorst
ID: 35240201
I think i should work without need for extra column with this change

=SUBTOTAL(9,INDIRECT("'Z:\Production Reports\[PR 01-2011.xls]11-01-"&TEXT(ROW()-1,"00")&"'!G$11:G$600"))



Kind regards

Eric
0
 

Author Comment

by:garyrobbins
ID: 35379128
SiddharthRout,

Is there a way of referencing cells in column B by cell address instead of using the INDIRECT & TEXT functions (they require that the source workbook open to run or update)?

Gary
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35379963
No only the INDIRECT requires the source workbook to be open.

I would suggest you the VBA method then. I can explain how it works if you want? It is very easy :)

Sid
0
 

Author Comment

by:garyrobbins
ID: 35385674
SiddharthRout,

Ok, I'm ready to explore the VBA approach.  I've studied the basics of VBA and am anxious to get an actual project working.

Gary
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35404991
Did you see the first post? You need to paste that in a module. Do you have a sample file so that I can explain it step by step?

Sid
0
 

Author Comment

by:garyrobbins
ID: 35405170
SiddharthRout:

Thanks for responding so promptly.  I can really use your help on this.

Attached is a file which I use to collect data fields from other large reports that are produced daily.  This report simply uses links to these reports.  I would like to be able to drag the bottom row and have the link references increment as required without having to manually edit them.  

As you can see, I have tried the INDIRECT/TEXT solutions already.

I’m looking forward to learning more about VBA in the process.

Gary

PCS-Facility-03-2011-EE.xls
0
 

Author Comment

by:garyrobbins
ID: 35720870
I'm sorry for the delay in responding to this solution.  I would like to award points now.

Gary
0
 

Author Closing Comment

by:garyrobbins
ID: 35741308
SiddharthRout:  Thanks for the prompt response.  Your VBA solution seems to be the only way to solve this problem.  I am not yet comfortable with VBA but I'm studying it and will implement later.  Thanks.

Gary
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

707 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

12 Experts available now in Live!

Get 1:1 Help Now