Reading Data From Workbooks Without Opening Them

Nov 21, 2007

I would like to read data from Worbooks through VBA code and UserForm without opening them. Is it possibe?

I know I can read data from Workbooks without opening them if I write this formula directly into a Worksheet cell:

='C:Documents and SettingsUserNameDocuments[FILE_NAME.xls]Sheet1'!$A$1

The problem is it won't work for my task. I just need to analyze with UserForm Controls and For Each loops through many cells and many big Workbooks.

If I try:

Private Sub UserForm_Initialize()
Dim aaa as String
aaa = 'C:Documents and SettingsUserNameDocuments[FILE_NAME.xls]Sheet1'!$A$1
End Sub

OR

Without opening the file if I try:

With Workbooks("C:Documents and SettingsjohnMy DocumentsmProjectfilename.xls").Worksheets("sheet1")
For Each thing ...
....
Next
End With

In both cases it gives me - Compile error: Syntax error, Expected expression.

I can also say that I definately don't mistake path, workbook's or worksheet's name
------------------------

If you're not quite sure that my explanations are clear I wrote some more below:

Reasons i want this:
It's just a lot of traffic/memory to Open/Activate/Close many Workbooks/Worksheets from 10MB files for just taking one or a few values to an UserForm :->

What I do:
I'm using several Workbooks to manage data. One of them consists of the Macro code (ThisWorkbook.) and the rest of the Workbooks are just tables with data I use. On UserForm with controls such as (ComboBoxes, CommandButtons, ListBoxes, Labels etc.) I find, visualize, compare and copy just the data I need from other Workbooks to ThisWorkbook(on a new worksheet) :->

The idea of my task is:
1. I have 10 files, each of them 10-20MB with data.
2. Now, I'm making 1 file with VBA code which analyse these 10 files and displays the information in it.

The general idea is that these 10 files are well structured but have many columns and rows and it's not convinient each time I need to find 3 numbers I need to open 10MB file, scroll 5 minutes, copy/paste the numbers, close the file...i just want an UserForm with several controls to do this job

Each of these 10MB files consist of let's say about 10000 rows and 100 columns. Between these rowns and columns there's data (or empty cell). Everytime I use one of these files I need different information. So, if I use the formula you gave me, I should copy exactly the same Workbooks in one file but with formulas.

With the macro code I just go through these rows and columns and find the specific data I need with For Each loops. Everytime I need different data. With 4 ComboBoxes I just select an year, a name, a code (by rows) and another code (by columns) and I get the needful info.

This info could be in one file, could be in many files, it could be in HZ45 cell (file 1), it could be in C5 cell (file 2), the next time I would need file1,2,3,4,5 with cells GF45, J7, KK88, DR8, Y90 etc. etc. etc. So, the problem is that every time I need different information from these 10MB files, each of them consist of 10000*100 cells*10 files = 10 0000 000 cells which I have to write the formula you gave me and it will become one 100mb excel file, which is no good.

View 9 Replies


ADVERTISEMENT

Opening Two Workbooks Using VBA?

Feb 6, 2014

I have a spreadsheet that I need to open two other workbooks to copy and paste data from.

The name of the two workbooks changes each day, and the location because they are filed in subfolders.

I have the following code, which works to open the first sheet but then comes up with the following error when trying to open the second sheet. "Run-time error '1004: Excel cannot access 'Hub PVA'. The document may be read only or encrypted".

The folder is not encrypted because when I was only opening the second document with the same code, it worked.

The code I am using is:
'DECLARATION
On Error GoTo ERR1:
ChDir "G:GENERALTRANSPORTDAILYPLANS"
Workbooks.Open Filename:="G:GENERALTRANSPORTDAILYPLANS"

[Code]....

View 3 Replies View Related

Opening Workbooks In A Folder

Dec 1, 2008

Is there a way to use a for next loop to open a workbook that is in a folder, then save and close the workbook then open the next workbook in the folder and do the same routine till all the workbooks have been updated?

View 12 Replies View Related

How To Work With Workbooks Without Opening Them

Apr 26, 2012

I am making a macro and I need to extract some data from workbooks. However, I have many workbooks and it would take time to the macro to open and analyze each of them.... is it possible to work with workbooks without opening them?????

For instance, I need to open a workbook and get all rows that contain the word HEXXX..... However, I have about 30 workbooks and it would take forever...

View 2 Replies View Related

Opening Workbooks Via Hyperlink?

Sep 3, 2012

I have a Sharepoint site which seems to be set up incorrectly as I cant even do a webquery with it, or sync Excel with it.

I want to be able to open up the Excel workbooks held in this one dir within Sharepoint take some data out of it pop it into another Excel workbook and move on down to the next one!.

So far all the code I have managed to locate causes errors, so I have managed to get a feed from the Sharepoint site which gives me a hyperlink to all the docs (as these can change). What I now need is some code to run through all the hyperlinks open the doc (if it ends in xls or xlsx as some are PDF's!) take the info copy it out and move on to the next one.

View 1 Replies View Related

Opening Workbooks From Macro In Toolbar?

Mar 13, 2013

What I'm trying to achieve.I'm trying to create a toolbar to have visible in excel which provides me with shortcuts to a selection of functions and some other useful documents.

I've created a document "Toobar 1.xls" in column B of which I have the file locations of the documents I want to open, the documents are moved from time to time and it is easier for other users to update the spreadsheet than vb.As you can see below I've written a piece of code to open up a document, I've created a function because there are a few documents I want to create links to and thought it would be cleaner to do it like this. This code is stored in "Module1" of "Toolbar 1.xls".

I've then created a new toolbar in excel and added a custom menu item and allocated it the macro "Pension_Credit_Calc".

When I run the code from within "Toolbar1.xls" it works fine, however if I try to run it from another workbook I get "run time error 1004". I suspect it's probably something to do with where I've stored my code,

PS. The reason I have not simply created a shortcut in the quicklaunch bar is that I will also be altering the workbooks once opened.

Code.

VB:
Function OpenUp(FileLocation) As String
Workbooks.Open (FileLocation)
End Function [code]....

View 2 Replies View Related

Opening The Workbooks In A Folder, One By One, To Make Changes

May 11, 2007

I'd like to create a macro which will

-go to a given folder

-open each of the workbooks in the folder, one at a time

-after opening the first wkbk, go to a specific cell address on the first tab of the wkbk

-paste in some values and formulas

-save the workbook

-open the next workbook, and repeat as above, for all workbooks in the folder

View 9 Replies View Related

Opening 2 Workbooks In Separate Windows

Dec 1, 2009

I have 2 workbooks open and I want to set up formulas from one linking to the other. When I toggle on the task bar between the 2 workbooks they replace each other within the same window so I can only see one workbook at a time. How do I set it up so I can have 2 separate windows open at the same time, one with each workbook in it? I tried 'side by side' in one window but the viewing area is too small.

View 9 Replies View Related

Personal.xls File Not Opening With Other Workbooks

Aug 25, 2008

I have a problem when opening Excel work books, The Personal file will not open automaticly. The file is in the XLStart folder. The link is "C:Documents and SettingsUSERApplication DataMicrosoftExcelXLSTARTPERSONAL.XLS. I have a desk top short cut I need to open first manually. Also the menu bar short cuts I had to my VB code and Macros will not work. Any body have any ideas what the problem may be? Im sure its a simple link problem but I don't know where to look.

View 2 Replies View Related

Opening Workbooks Based On Date In The File's Name

May 30, 2009

I'm trying to develop a macro to amalgamate some data on currency exchange rates that are stored in different files with the dates saved in the file's name. The code of the macro I recorded when opening an example of such a workbook is:

View 5 Replies View Related

Opening Multiple Workbooks In Alphabetical Order?

Dec 3, 2012

Work have just upgraded from 97 to 03 (very with the times ) and when opening multiple workbooks, 03 behaves differently.

With 97 I could select many sheets from the open window and excel would open them in alphabetical order. Now we've moved to 03, the order seems to be completely at random. It's a real pain, as the set up of the workbooks we use has everything linked together. In order to keep everything working sweet, various groups of workbooks need to be open at once. Previously it was easy to find a workbook in the task bar, but now they're scattered everywhere. We don't use a set list of workbooks - the selection we need to open varies quite a bit, but there's usually at least 20 or so.

View 5 Replies View Related

Opening Workbooks And Running A Unique Macro From Them

Jan 22, 2008

I have a macro that at the moment just opens a workbook SpreadsheetA.xls,

Sub OpenA

Workbooks.Open Filename:=C:DocumentsSpreadsheetA.xls, UpdateLinks:=0

End Sub
SpreadsheetA.xls has a macro called "ExpectedRun" which is currently operated by clicking a commandbutton.

What is the code to run the "ExpectedRun" Macro in Sub OpenA?

Eventually I'll be opening a bunch of these workbooks, each with its own unique "ExpectedRun" macro, so is there any special command to call on the "ExpectedRun" macro for specifically the opened workbook?

View 9 Replies View Related

Workbooks.Open Not Opening File Or Workbook

Oct 27, 2006

I was wondering if anybody could catch an error in the following code. I have a file, let's call it a "Guide" which is opened by user and at this time this file has only one purpose - to help user choose the program. After clicking on the "Choose Program" command button, an Inputbox appears where the user types in a program. Then the code should open the file with this program and this is pretty much it. But something is not working with the code below, and I do not see anything wrong with it after looking at it for so long. It just does not do antthing. how to handle the "Choosing" option

Private Sub CmdBttn_ChooseProgram_Click()
Dim sFilename As String
On Error Goto ErrorHandler
sFilename = "Approval_" & Application.InputBox("Input Program")
Workbooks.Open Filename:="C:Documents and SettingsjsmithDesktop" & sFilename & ".xls"
ErrorHandler:
'if file name does not exist error message should display. Not defined yet
End Sub

View 3 Replies View Related

Excel Opens Multiple Workbooks When Opening Any Workbook?

Jan 27, 2005

The same two workbooks open when I open any other workbook. They also open up when I open Excel by itself.

View 9 Replies View Related

Reading Data In Each Row

Mar 4, 2010

I'm trying to write code that looks at the range W(rowid):Z(rowid) and lists each cell value in a listbox. The row id is coming from the listindex of combobox1. I know the rowid part is correct and working because other operations in my worksheet are using it fine. Here's what I've written so far:

With Worksheets("DATA")
For I = 0 To 4
ListBox3.AddItem .Range("W" + I & rowid)
Next I
End With

View 9 Replies View Related

Reading Same Data In Different Sheet

Jul 17, 2014

In sheet 1 data 123. In sheet2 there is also data 123. In sheet3 will automatically data that is same 123 after reading sheet1 & sheet2. Any data with figure that is same in sheet1 and sheet2 will be reading in sheet3.

View 4 Replies View Related

Reading A Column Of Data Into An Array.

Aug 14, 2006

I need the function to be looped for all the values in the first column and I'm told I need to enter all the values in the first column into an array. how do I enter the values in a column into an array in VBA? The range of the rows in the column varies over the worksheets that I need this function for so the array cannot be of a fixed range.

View 7 Replies View Related

Reading 2 Columns And Extracting Data Under Certain Conditions

Oct 2, 2011

I have two columns. In one people either saw Red, Blue, or Green. In the other people either chose One, Two, or Three.

I would like to get excel to read the first column, find all the times someone picked red, then look to the column next to it and see if they picked the number One. Then I would like it to count that situation. Then I want to do it for Two and Three. In the end I would have something that looked like this


---------One----Two---Three
Red-------5------8-------9
.
Blue-------4------5-------3
.
Green-----4------2-------6


Generated from something that looks like this

Red One
Blue Two
Blue Three
Green Two

Some kind of biconditional countif maybe

View 1 Replies View Related

Data Types When Opening CSV Files

Sep 20, 2012

I have a csv file. When I open it by double clicking, all the finance figures appear as currency with the currency symbol. I can use the SUM function on these and it's perfect.

However, when I open this file using a macro, these same numbers look the same, except that they are now left justified and are text because the SUM function no longer works. If I select a range, I get the count of the number of items selected showing at the bottom of the screen but not the sum.

I have tried opening the file using the OpenText function which has several ways of setting a date format to the fields but nothing for numbers.

I have even tried, in the macro, selecting a cell with numeric 1 and then selecting the range and pasting the 1 as a multiply function but this doesn't work either.

View 2 Replies View Related

Copy Data From Another Worksheet Without Opening?

Jun 26, 2013

I have this VBA work fine for me but I want to chage this to when it copy then it select active sheet and active cell.

Sub test()
Dim wb As Workbook, wb2 As Workbook
Dim ws As Worksheet

[Code]....

View 3 Replies View Related

Paste Data In A File Without Opening It

Apr 29, 2009

Is there a way to paste data in a file without opening it?

View 21 Replies View Related

Add Data To A Closed Workbook Without Opening It

Apr 10, 2007

I found many examples on this forum of how one can pull in data from closed workbooks, or copy it and have it stored in the active sheet. So far so good, but I need a solution which would do the opposite - I need the macro to take a range of data form the active sheet store it in a closed workbook and save any changes in the target workbook without opening it.

View 2 Replies View Related

Opening A File Without Opening A Workbook

Apr 17, 2007

I have a need to open a file from my companies intranet. My current method was to open said file via the method that the recorder gave me. However, I would like ot be able to open a said file without having to start open another workbook.

This is the path:
[url]

So the command is this:
Workbooks.Open [url]

Links are not actual links

So what I need to know. Is how can I open this file without opening a workbook. I haven't been able to use the VB "Open Statement" to open a file and I don't believe that I've been successfull using the Filesystem object either.

View 9 Replies View Related

Clear Data On First Time Opening File?

Jan 16, 2013

I have a file that I want to clear certain cells and all option buttons when first opened. I then want the user to be able to save and close the file with the data they have entered. When they go to reopen the file I want the data they entered to still be there. I want the user to get the blank file off the company's server and then save it to there machine when it has been completed and when they go back to this file the information is still entered. I have attached the file.

Request Form 2012 Draft4.xlsm‎

View 1 Replies View Related

Data Validation Disappears When Re-opening Spreadsheet?

Aug 23, 2013

I add data validation into 4 columns and when i re-open the spread sheet after saving it, it clears all validation.

Although it clears the validation, the place where it gets the data from is still there. i have also unfroze panes and is still clearing data validation

Attached is the spread sheet. The data validation is in columns A, G, H and I on the 'unsourced' page and is getting the data frfom the 'Sheet1' Page.

View 2 Replies View Related

Copy Data From Closed Workbook Without Opening

Nov 24, 2004

I amended the range with the code from the J.Walkenbach's book. However, the closed file "budget.xls" will be populated weekly with same columns but different number of rows. For example, if file budget.xls has data populated over 18 columns and 50 rows, the code will populate row 31 to 50 in the active workbook with "zero" values. Need the code will copy all the values in the closed file in Sheet1 over?

Private Function GetValue(path, file, sheet, ref)
path = "d:files"
file = "budget.xls"
sheet = "Sheet1"
ref = "A1:R30"
Dim arg As String
If Right(path, 1) <> "" Then path = path & ""
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If.......................

View 3 Replies View Related

Data Lost Opening Text File

Mar 1, 2007

I'm working with a list of different manufacturer part numbers, that must be represented in TEXT format only! The file with manufacturer part numbers exported from ERP system to TXT/CSV formats. When I open it in Excel , manually in "Text Import Wizard" I define Column Data Format as Text.

Examples:
1. part number 3214-4-5 turns to 05/04/3214
2. part number 0005487 turns to 5487
3. part number 223878615654 turns to 2.23879E+11
4. part number 4303.240600 turns to 4303.2406

Is anyway to do it automatically from VBA? I try to record macro , but it does not contain "text format".

View 2 Replies View Related

Opening Protected Worksheets To Update Linked Data

Aug 3, 2006

I have the following code that should open all EXCEL workbooks in a
specified path, and unprotoect any password-protected worksheets to allow
for Link Updates, then close the workbook after password protecting it.

sub UpdateAllLinks()
Dim vLinkSources
Dim iLinkSource As Integer
Dim AnySheet As Worksheet
sPath = " C:Documents and SettingsShaneMy DocumentsHarcourt
Assessmentspassword"
sName = Dir(sPath & "*.xls")
do while sName <> ""...............

View 9 Replies View Related

Reset Data Validation List All The Time When Opening File?

Jun 11, 2014

When opening the attached file, for some reason, I have to again select the cells from column A in tab "Transactions" and go to Data Validation and select again LIST - only then the data validation from list resumes working. When I close the file after saving and open it again, the data validation does not work - I have to again go to Data Validation and again reselect LIST (making sure, of course, that I do not mess up Source) to have Data Validation list run again.

what is wrong with list validation when opening the file.xlsx‎

View 4 Replies View Related

Opening / Copying Data From Multiple Files Into Master / All With Different Names

Sep 11, 2013

I have a lot of files with data that i need to copy into a master file.

I could open each file copy the data i need and paste it into the file. But I know there must be a way to do a loop macro.

All the files are labled "Sauce Data "Date"". all the data is in the same place in each file. I can easy have a list of all these file names in a tab in a main file "Main Data".

I what to be able to open each file copy from tab "Sauce info" A1:B65, and paste into "Main Data", tab "main" and then create a long list of data.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved