473,586 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I fix dynamic vlookup slowing down when referenced workbook is read only?

61 New Member
I'm using VBA in excel 2010. I figured out that i could use vlookup to access workbooks without opening them up this is the code i've got.

Expand|Select|Wrap|Line Numbers
  1. For i = 0 to Ubound(myData,1) -1
  2.   [A2].Offset(i, 2) = myData(i + 1, p + 1) 'partnumber
  3.   [A2].Offset(i, 3) = "=VLOOKUP(" & CStr([A2].Offset(i, 2).Value) & _
  4.     ",'" & myPath & "Sheet1'!$A$2:$C$10000,3,FALSE)"
  5.   [A2].Offset(i, 3) = [A2].Offset(i, 3).Value 'convert formula to a value
  6. next
  7.  
This works great but the issue i'm having is that if someone has the workbook that i'm referencing open making it read only, the vlookup function drastically slows down. If i have 100+ entries in my array this can take quite a while to finish.

Is there anything i can do to fix this or some other option available that i can try.
Feb 13 '13 #1
7 1931
Rabbit
12,516 Recognized Expert Moderator MVP
Your question has been moved to the Access / VBA forum from the VB6 forum.

You could make a copy of the workbook and then run your vlookup against that.
Feb 13 '13 #2
zmbd
5,501 Recognized Expert Moderator Expert
Rabbit's suggestion of saving the "read-only" workbook to a new file and working against that is great alternative; however, you may not have the most up-to-date data if someone is changing entries.

There is another option that you should try to do, not a guaranteed fix by any means, is the next time you have the workbook open in edit mode, set it up for sharing: Use a shared workbook to collaborate. Depending on what you need, you more than likely can turn off the "track changes" option; however, that depends on what you are doing with the workbook.
I have a workbook out on our network drive that my labtechs enter their data into when I have the database down for backups and this what I do so that I only have one workbook to import and validate data from.

As for why you're seeing a slow down: despite what you may have been lead to believe, the code you are using is actually "opening" the workbook, in that, it has to have a lock on the cells in the worksheet referenced in order to read the values. It is just that the worksheet isn't made the "active" worksheet in the user interface so it is not so obvious.
Feb 14 '13 #3
Rodney Roe
61 New Member
@ zmbd that makes sense why it takes so long to get the data.

Thanks guys for the help, do to the nature of what these workbooks handle i can't make them shared so i'll try to make a copy of the workbooks get my data and then delete that copy that way every time i run my program i'll get the latest and greatest.

Thanks,
Feb 14 '13 #4
Killer42
8,435 Recognized Expert Expert
On the topic of shared workbooks, I'd like to make a suggestion.

Never, ever make a workbook shared for any reason whatsoever. Shared workbooks are a curse and a plague.

Alright, perhaps I'm being a little melodramatic. But in all seriousness, unless things have changed a lot since Excel 2003 (and if so, hooray!) shared workbooks restrict you from doing pretty much anything useful.
Feb 20 '13 #5
NeoPa
32,566 Recognized Expert Moderator MVP
While Z is correct in stating that workbooks that are referenced do need to be opened, albeit invisibly, the issue with workbooks that are already open and locked is a level on from that. When a locked file is found it will wait for a timeout period to expire before giving up repeatedly trying to open the workbook.

Opening a workbook is serious time compared to working within an open workbook, but waiting for timeouts to expire is another level of delay entirely.
Feb 20 '13 #6
zmbd
5,501 Recognized Expert Moderator Expert
Neopa,
I usual, I was simplifying the actual process; however, you are exactly correct with the additional delay. It would be soooooo aggravating for me to have to wait like that!

Killer42,
My experience with shared workbooks is limited at best; therefore, I had not encountered the issues you (and after a quick Google) others appear to have encountered.
What I noted is, in general, that the more complex the workbook, the more likely it is to start behaving badly. SO maybe a tad melodramatic (IMHO - ;-) ) HOWEVER, a warning well taken - especially in a business/production environment where up-time is critical.
Feb 20 '13 #7
Rodney Roe
61 New Member
I would like to post my rusults,

I first tried to copy my files using the function "FileCopy" but found out that it errors out if the workbook is already open by someone. Due to the time delay like NeoPa discussed i didn't want to open each file individually and copy or search for my data.

So I used the FileSystemObjec t instead. This is what I did,

Expand|Select|Wrap|Line Numbers
  1.     sourceFolder = "\\usbla-s004\misc-eng\ITEMDRAW"
  2.     myPath = "\\usbla-s004\main-eng\CUSTOMER ORDERS\Temp\"
  3.     Set fso = New FileSystemObject
  4.     Set myFolder = fso.GetFolder(sourceFolder)
  5.     i = 0
  6.     ReDim itemdraw(0)
  7.     For Each myFile In myFolder.Files
  8.     DoEvents
  9.         myFile.Copy myPath & myFile.Name 'copy file to temp folder
  10.         itemdraw(i) = myFile.Name
  11.         ReDim Preserve itemdraw(UBound(itemdraw) + 1)
  12.         i = i + 1
  13.     Next
  14.     Set myFolder = Nothing
  15.     Set fso = Nothing
  16.  
By using the FSO i could copy all my workbooks without getting and error if one of them is open by another user to a hidden temp folder which can be overwritten everytime the form loads. I used this on the initialize form event and added the file name to my array. This made my program work a lot faster by searching my array for the specific workbook I needed and addeded it to my vlookup function.

Thanks everyone for your help and info, i'm a self made programmer who loves looking at all these posts to learn more.
Feb 20 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

16
9901
by: TheKeith | last post by:
I'm writing a script with a while loop in it. How can I get it to go slower so that it doesn't appear to happen all at once--so that it looks animated--basically. I tried the setTimeout(500) in the last line of the loop, but that just messes things up. Any help would be appreciated--thanks.
1
1311
by: vaury | last post by:
I'm having difficulty making a list (both drop down and radio button) read only; I am successful when I attempt to make a text field read only. Any suggestions on what java script I use to accomplish this? Thanks.
5
2716
by: tony | last post by:
I'm using PHP 5 on Win-98 command line (ie no web server involved) I'm processing a large csv file and when I loop through it I can process around 275 records per second. However at around 6,000 records this suddenly drops off to around 40 records per second. This is a big problem as the "live" list is over 4 million records long. I'd...
3
1801
by: Dan Stromberg | last post by:
I have two different python programs that are slowing down quite a bit as their memory use goes up. I'm not really sure if this is some sort of CPU cache effect, or if it's something about python's garbage collector taking more time, or what. One of the programs is one of those "how fast is data moving through the pipe" measurement tools,...
7
2578
by: davidst95 | last post by:
Hello, I have a program that runs a long process. I tried to add a thread to check if the use hit a cancel button to abort the process. Dim t As Threading.Thread t = New Threading.Thread(AddressOf StartProcess) t.IsBackground = True t.Priority = ThreadPriority.Highest t.Start()
5
2296
by: myke | last post by:
Whenever I use the DVD ROM on my PC, it slows the computer down really badly. Whether I use it to copy files onto a CD/DVD, or install a program, the CPU usage goes to around 55% (which is totally unusual) because in the processes field there is no proces with that much usage. I use this PC for a five or six months, this is new, for last two...
3
1948
by: karl98 | last post by:
Does anyone else experience slowing down of a web conferencing session when 5 or more people join in the meeting? Our web conferences slow down considerably and are driving me nuts.
23
2198
by: Dan Tallent | last post by:
A textbox has a attribute for ReadOnly. This seems like such a simple concept. When a textbox is set to read only the user cannot change the contents of the field. I have been trying to find that missing ability for other predefined controls in C#. The radiobutton, checkbox, and combobox controls do not share this ability. I find...
0
1273
by: shale | last post by:
Hi, I have an ASP scripted business web application connected to a SQL 2000 server, that suddenly after a few hours is slowing down. it becomes so slow it can take up to a minute to load each page, wich usually takes 1 or 2 seconds. This only occurs on the server and not on the clients running the same application, this makes me think the...
3
2848
by: Echosei | last post by:
Hi there, I recently purchased an HP pavillon dv3 -CORE i7 -Windows 7 premium -300GB Harddrive -2GB RAM PROBLEM: The whole system slows down exceedingly everytime I use it. I think it's a virus because it started happening when I loaded a lot of files from our previous computer into my laptop. The most obvious symptom of it slowing...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.