We have several salespeople who maintain a workbook tracking their workflow. I want to compile the customer account number, account name and deal number for each rep to another workbook. A new sourcebook is started each week. This code is in the target book
Public sourcebook As Object 'the workflow workbook
Dim wsc As Double 'the number of pages in the workflow
Dim col As Long 'the column in this workbook for returning values
Dim IntEndRow As Double 'the end row in this book
Dim SrcEndRow As Double 'the end row in workflow
Dim findval 'the column workflow where the sourcedata is found
My code allows the user to select a workbook and then loops through each sheet in that book searching for the column which has the info I need, this changes on each sheet as the reps each deal with different types of customer as so take different details. I solved this by having column headers in the target book and searching for them in the sourcebook.
This code works when I step through it but falls over at the "Set sourcebook" line when I run it where it returns a breakpoint error.
I am making a macro that requires that user to enter a directory path into a input box and the macro will open the file. Right now it works fine bit i would like to change the code so that instead of using an input box it brings up a box that will allow them to browse files on their computer and then select one to open.
I have this script below which I am trying to modify to pull information from each file in the folder and draw cell values from different sheets within the file. I have the script working prior to the modification but the difference was I was pulling all the different cell values from the same single sheet in the file. I believe the issue I have (Excel reporting that file is already open and then eventually erroring out) is because the way I'm going about this is causing Excel to open the file multiple times without closing (my coding isn't the best) here -
Do While fn "" On Error GoTo Handler: Set ws = Workbooks.Open(myDir & fn).Sheets(7) Set ws2 = Workbooks.Open(myDir & fn).Sheets(2) Set ws3 = Workbooks.Open(myDir & fn).Sheets(3) Set ws4 = Workbooks.Open(myDir & fn).Sheets(8) Sheet4.Range("a" & Rows.Count).End(xlUp).Offset(1).Resize(, 6).Value = _ Array(ws4.Range("AI6").Value, ws.Range("ac4").Value, ws2.Range("ac4").Value, ws3.Range("ac4").Value, ws4.Range("ac4").Value, myDir & fn, fn & "-" & ws.Name) Workbooks(fn).Close False fn = Dir Loop I'm hoping there is a better way of pulling information from multiple sheets in the file that actually works as the above now I think it through is obviously not very clever.
A second issue I have is that whilst some people running this script don't have access to save to this network drive (so can not save changes), some users CAN. Is there a way I can force the script to open these files as Read Only or ensure that they are closed UN-saved - just to cover any mishaps??
I'm trying to open multiple files based on an array of WBnames that are on a 'Dashboard' tab, but I only want to open them if they are not already opened. The code below doesn't seem to check if they are open and just opens everything....
VB: Sub OpenWorkbooks() Dim WorkbookOpen() Dim WBnames() As String 'Array of WorkBooks to be Open Dim WorkbookCnt As Integer
Dim myname As String myname = Application. GetOpenFilename
I use it to attempt to open first a QuickBooks file and then an excel workbook. The Quickbooks file opens fine. The Excel workbook never appears to open but I do get the full file pathname to my excel workbook returned which I then parse off to get just the workbook name.
Why would it behave this way? I open both these files manually all the time.
Also, I'm trying to use a filter as follows:
myname = Application.GetOpenFilename("*.QBW")
I get a compile error saying that I'm calling the function wrong.
i have a master file which needs to be updated by several other sourcefiles. I did a macro running from the master file which opens all of the sourcefiles one by one, copies the relevant info from the sourcefile to the masterfile, and closes the sourcefile, then moves to the other one. i know this is probably not the case, but the code below seems to behave randomly: sometimes it works, sometimes it bugs by saying file not found runtime error 1004:
Dim masterfile As String masterfile = "Master.xls" Dim sourcefile As String CurrentWeek = InputBox("Enter current week number") CountWk = 35 sourcefile = "Source" & CountWk Workbooks.Open (sourcefile) ....
The last statement causes the error. Both master.xls and source35.xls are in the same folder.
the VBA code to allow a user to navigate to any of our network directories and upon selecting (using workbook getopenfilename hopefully) the proper folder on their directory open each txt file (delimited with a pipe) and then save the active file as a xls file and then close it and move on to the next file. I am pretty sure this will take a do while statement but I am not sure how to write it.
I want to know if its possible to write a macro that will prompt me to open a document, then once open it will copy data and paste it into the working spreadsheet. I have a mini macro that cuts and pastes data elsewhere in the sheet but at present I am manually opening a file then copying all and then pasteing the data which is rather slow.
I'm having problems with the multiselect argument of the getopenfilename function. I've used this dozens of times with no problems, but now it doesn't work for me. I tried copying and pasting code that works in one module,
What I'm using is
Sub OpenFiles() Dim vFiles As Variant, iNumfiles As Integer
If IsArray(vFiles) Then For iNumfiles = LBound(vFiles) To UBound(vFiles) MsgBox vFiles(iNumfiles) Next iNumfiles End If
pretty simple, expect that when I select multiple files in the open dialog box, vfiles is a string containing one of the filenames, not an array containing them all! (by selecting, I simply highlight all the fiels I want and click open)
i would like to use the application.getopenfilename to select multiple files, then with these file's would like to be able to use them to create a email with these files as the attachment. then move the files to a new location and delete the originals.
I have a macro to find me a document from a certain details, but in some circumstances their may be multiple applicable documents, I know nothing of user forms, but how to I find all the documents, show their "modified date", "Name","File type" and select one or which several to open.
My current code:
Code: Private Sub OpenPDF() Dim Ans Dim TheFile As String
To have something more like a form popup showing for a search within a folder for files containing 'Brians Store':
Open? Name Date O "Quote Brians Store - ProductsA.xlsm" 1/2/12 O "Quote Brians Store - ProductsB.xlsm" 1/1/12 O "Quote Brians Store - ProductsA.xlsm" 1/5/11 O "Quote Brians Store - ProductsC.xlsm" 1/4/11
And I may want to open the 1st, 2nd and last files.
I do'nt know really my problem is regarding excel or with windows, actually stange thing starts happening, I open multiple excel files but only one general excel instance is showing on the task bar. If I need to switch between the file I have to minimise the one I am using and then select other to open it. Even shortcut Alt+Tab switch is not working to switch between the excel files.
I need to open 9 files in different worksheet. If the files is not present i want to get to the next available one. I don't understant the following code will work once, but not 2 times in arrow. The error handler routine works only once and then if the file is not present I will get a error 1004 (on this line Workbooks.Open Filename:="c:" & openfile). I know that the file is not present but the error gets trap the first time and not the second time.
I'm trying to build a macro to open multiple files at one time that will always be saved in a consistent drive. The problem is that sometimes there will only be one file for a month (ie only at month-end) and other times, there may also be additional files for different dates throughout the month. I wont know ahead of time how many files there will be, but they will always be saved in the same file name type that is "FILE DESCRIPTION MM-DD-YYYY". How can I build a loop that looks for a file on each possible day but doesn't error out if the file doesn't exist?
I want to make a chart with the time in x axis and all of the S in the y axis. The problem is I want to be able to choose which S that I want to put in the chart. Example, I want to make 2 chart with S2,S3 and S5 in the first chart and S1 and S6 in the second chart. What I want is when I click the button 'chart', a pop-up appear and ask which S that I want to include in the chart.
I've have a spreadsheet where 4 cells are linked to another workbook via a vlookup. the problem i have is that a lot of users can update this external book, or it can be saved as a seperate spreadsheet somewhere else on the network. If it was up2 me i would have them only update the one sheet, but as it stands its not. So what i want to be able to do is put some code onto a button on the sheet, from here i want the: Application. GetOpenFileName
method to open....but from here i want them to be able to pick the cells where the data is situated. Any clues..... i can get as far as them selecting a workbook. Do you think i will need to create another userform?? Maybe RefEdit? I'm not sure.
I have two columns, Account Number and Account Type. I already use Data Validation on Account Number to make sure it is numeric and on Account Type to make sure the user picks from a drop-down list. I want it so that if a user inputs an account number, it forces the user to automatically pick from the drop-down menu in the account type column, otherwise post an error.
I have 40 files in one folder which I named it as "CA" + month's name that I am working on. I need to do analyse these files monthly and save it under new folder. how do I automatically save them in new folder and name them for that particular month. Also, each file has worksheet which has one cell as "Aug-07" and the cell next to it has number of that month that is "08". How do I automatically change this also based on the name of the file, because file name month and month in the cell are the same.