[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Opening several workbooks

Posted on 2013-12-13
6
Medium Priority
?
207 Views
Last Modified: 2013-12-16
Using vba and Excel - I may have 5 workbooks where I need to find Emp ID in the oldest workbook even though it may be in several workbooks.   What is the best way to approach this?
0
Comment
Question by:leezac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 35

Assisted Solution

by:[ fanpages ]
[ fanpages ] earned 1000 total points
ID: 39717196
Hi,

Determine the "oldest" workbook (by gaining either the "Date Created" or "Date Last Modified" of each) of the five workbooks, & then open just the workbook with the earliest date (depending what your definition of "oldest" will be).

Then search that single workbook for the "Emp ID" required.

You may have to determine what the course of action will be if two (or more) files share the same "oldest" date.

BFN,

fp.
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 1000 total points
ID: 39717239
Yes, for only 5 workbooks, the brute force method is probably best if it's a one-time operation.
If you need to do this over and over, you'll need a macro to check timestamps of the files, open them, search and (if needed) close and repeat for the next oldest.  When done it should either send a message telling you which file contained the item or tell you that the item was not found.
There are some other strategic issues with this, like telling the macro where to find the workbooks (especially if they're not in a fixed location) and what if they timestamp updates...do you want the one that was CREATED earliest, or MODIFIED earliest? And there may be some other things, like is the EMP id on a fixed page ("Sheet1" or would you need to search every sheet in the workbook?  Will the cell contain the exact number or will it be mixed with other things, etc.
0
 

Author Comment

by:leezac
ID: 39717245
If the oldest does not have the EMPID do I close it
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 22

Expert Comment

by:rspahitz
ID: 39717256
That's up to you, but that would probably make sense, especially if you increase from 5 to a dozen or more workbooks.
0
 

Author Comment

by:leezac
ID: 39717267
Can I get a code example

is this a do while or if then else>>
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 39721719
I can't create the exact code on my current system, but see if this helps...

Dim strFileName as String
strFileName = Dir("*.xls")
Do
   ProcessExcelFile(strFileName)

   strFileName = Dir
Loop strFileName <> ""

...

Open in new window

Sub ProcessExcelFile(FileName as String)
   Dim xlFile as WorkBook
   xlFile.Open(FileName)
   '...
   xlFile.Close
End Sub

Open in new window


Again, this may not be exact, but should be somewhat close...the harder part is working with the opened file to dig in and check all the pieces, since you'll have to examine the workbook's sheet's cell's content.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

649 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