Dynamically referencing worksheets from a closed workbook.

DCM - Albert

New Member
Joined
May 4, 2009
Messages
33
I've done quite a bit of searching, and apologize in advance if there is some obvious answer to this question I just haven't been able to come up with yet.

I'm reading data, from specific cells off a closed workbook. When the sheet that needs said cell data is activated, it automatically opens the workbook and references the sheet nessecary. The issue I've come across, is I now need to access another workbook (Easy to open) with 12 sheets 1 for each month, and only read from the worksheet of the actual Month...

Kind of lost on how to possibly make this work. I basically need something like:

=location/[workbook.xls]Month(Today())!cell

I realize that doesn't work, looking for another way around it. Any advice is greatly appreciated.

Thanks in advance for your help,

Albert
 
I'm guessing Mark is offline at this time, so I'll butt in. ;)
Basically, yes, but your code will be neater and easier to alter if required if you add a couple of variables:
Rich (BB code):
Sub RetrieveVals()
Dim wb As Workbook
Dim wksProd as Worksheet, wksMonth as Worksheet
Dim strMonthName As String
 
   '// Grab the full name of the current month//
   strMonthName = MonthName(Month(Date), False)
 
   '// updates link, no change//
   Set wb = Workbooks.Open("http://companyweb/compliance/Shared%...Compliance.xls", True, True)
   wb.Close False
 
   Set wb = Workbooks.Open("http://companyweb/locks/Shared%20Doc...ock%20Desk.xls", True, True)
   '// updates value//
   Set wksProd = ThisWorkbook.Worksheets("Production")
   Set wksMonth = wb.Worksheets(strMonth)
   With wksProd
      .Range("C29").Value = wksMonth.Range("E14").Value
      .Range("D59").Value = wksMonth.Range("k15").Value
      .Range("L46").Value = wksMonth.Range("F1").Value
      .Range("C2").Value = wksMonth.Range("P9").Value
    End With
 
 
    wb.Close False
 
    Set wb = Nothing
End Sub
for example.
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Really appreciate the help. I've gotten by with my "ghetto" coding so far, and made it all work. You guys just made my life a little easier!!!

Thanks again.

While I have your attention, I have another hopefully short question. On Sheet1, there is a layout of information. I need to count all the occurances that happened on each day of the month. That is the information I'm using the afore mentioned code for. Is there an easier way to count than:

At the end of the row, on a blank square in white letters I input =day(E5) for the numerical date. I then make a calender, and each numerical date (day and month) that matches I sum together for the total for that day. The current way I do this is:

=IF($O$15="","",SUMPRODUCT((Completed!$O$6:$O$500=DAY($O$15))*(Completed!$N$6:$N$500=MONTH($N$17))*(Completed!$E$6:$E$500="0. Newbie"))+Production!E33+W26)

Where o15 = the calender date, o6 and n6 are the date completed in day/month format only, and e6 is the step that was taken.

So if the day/month match, it counts all the occurances. I imagine there is an easier way, though I'm not sure its clear enough for anyone to understand.

If this makes sense to anyone, I'd appreciate a little insight.

Albert
 
Last edited:
Upvote 0
Rory may well discern that last bit, but for me, it would be a might bit handier if you could post an example wb. Some folks don't like downloading attachments, but for us slow typists, easier than recreating.

BTW, very glad we were able to help thus far :)

Hitting the rack, a good day to all,

Mark
 
Upvote 0
To hopefully clerify the question. On the workbook, on sheet "Processing", in row "Approved" I want all the occurances of anything on the "Completed" worksheet to be counted, if the date matches the date of the column, AND the Status matches "Approved" or "Newbie".

The trouble I've had so far, is that a) The completed date, is in date/time format so its trying to match the date AND time, which obviously isn't matching. b) the only way I'm able to count more than 1 status, is by basically remaking the entire table, and using a seperate formula, then adding that to the other formula. If you unhide the columns, and change the font color you will see what I mean.

Hopefully that makes it a little more clear.
 
Upvote 0

Forum statistics

Threads
1,217,259
Messages
6,135,519
Members
449,945
Latest member
noone12344444444

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