A VBA macro uses the Shell command to open several DOS command boxes. Each DOS command box is copying a file from one location to another. Since I am copying the files over a network, it is most efficient to copy the files in parallel (simultaneously) rather than sequentially. I would like to pause the program until all of the files are copied, i.e., until all of the DOS command boxes have closed. Is there a way to pause the program until all command boxes are complete?
If the admins or you would like to change or recommend a change, I am trying to figure out what the code would look like for cells B22:B28. I need it to count the number of occurrences of the part number in A4:A17 and then combine the applications from the corresponding cells in column F (F4:F170 into a single cell (B22:B28).
On sheet 2 I would manually copy/paste the list of part #s from sheet 1 and remove duplicates. The add the formula that I can't figure out into column 2.
I am trying to run multiple applications. I can run one application i.e.
Application.Run (Sheets("Sheet2").Range("A8").Value) but not multiple i.e Application.Run (Sheets("Sheet2").Range("A8").Value) & Application.Run (Sheets("Sheet2").Range("A9").Value) at the same time.
I have also tried Application.Run (Sheets("Sheet2").Range("A8:A9").Value) but to no avail.
I have a macro that cycles every 5 minutes. I have tried everything I can to get this program to run while I modify a sheet in the workbook to no avail. I have however figured out that if I open up a separate excel application that my macro can continuously run without preventing me from modifying the other application. Now I need to figure out a way toggle between the two excel application windows if a condition is met. The basis of this is to allow production associates to create a schedule and modify it while a macro looks into the defect database and if a defect becomes too problematic, the macro interrupts the schedule to display the issue.
Is there any way to access all the applications which are opened through only Excel.. Like creating a menu which will list all applications that are running.. like Word., other excel workbooks,Notepads etc?
I am using MS Word to create a list to go into Excel, it seems advantageous to do it this way because I'm using the Heading Outline Numbering feature of Word.
Presently my macro assumes the word document is closed. How do I modify the macro to:
1. check if the file is open? 2. if already open, switch the focus to word? 3. switch the focus back to excel?
Sub GetDataFromWordDoc()
Dim FileToOpen As String
FileToOpen = ThisWorkbook.Path & "5Whys.doc" Sheets("Data1").Select ' MsgBox "Active sheet is " & ActiveSheet. Name ' My check ActiveSheet.Range("WordClear").Select ' Existing data to remove Selection.Clear
Set appWD = CreateObject("Word.Application")
' here I would like to check if the word file is open
so i'm building an application that'll allow users to manipulate records in Excel with just a GUI, using Userforms, Modules and Class Modules. it's all working but i'm feeling like i skipped a little on structuring it properly.
for example (from my Java work in college), you'd call just one object from the main method, which would create a GUI object, and create/manipulate instances of the different Classes when buttons are pushed. basically you one object whose main created other objects, who ran procedures, etc. what i'm hoping for is to make it as modular and easy to maintain as possible. would anyone have a good resource for optimising a medium-sized application? (the tips Excel/VBA Golden Rules. These Should NOT Be Optional were very good, by the way.)
I'm using a VBA UserForm (ShowModal=False) as the front-end on a spreadsheet for logging purposes. Here's the progression of the problem:
1. I have the UserForm loaded and the cursor is in any given textbox/ combobox on the form.
2. I switch to another program, then come back to the UserForm.
3. The cursor no longer appears in whatever textbox/combobox I was in when I left the UserForm. If I type, nothing happens (I have to click the field again first, then type).
However, if I TAB, it will go to the next field in the Tab Order just fine. It seems that the control has "pseudo-focus"--it knows which field to tab to next, but the control won't accept input unless you click it. The odd thing is--this UserForm has a button which launches another "child" UserForm. That "child" UserForm does not have this problem.
programPath = "C:Program FilesInternet Exploreriexplore.exe" ' works 'programPath = "iexplore.exe" ' does not work Shell programPath + " " + fileToLaunch, vbNormalFocus
but the drawback is that the invoked program (iexplore.exe, at least in my case) needs to have the FULL PATH to where the program exists = the "C:Program FilesInternet Explorer" which may or may not work on someone elses computer. This hardcoding will not work and is not transportable.
Is there a trick to find where the executing program lives? or launching it without the path?
I am trying to figure out how to count all open workbooks, then count all worksheets within the workbooks and come up with the total amount of worksheets in a message box. I know that it sounds very simple and probably is, but I really can't figure it out.
I need to develop a VBA that counts all worksheets named sheet1 within all open workbooks in addition to many other useless tasks. I have spent many hours trying to figure out how to do that. My guess is to use some sort of with statement, but my efforts have been unsuccessful.
Sub CountWKS() Dim wb As Workbook Dim msg As String Dim myTotal As Long For Each wb In Workbooks msg = msg & vbLf & wb.Name & vbTab & wb.Sheets.Count myTotal = myTotal + wb.Sheets.Count Next MsgBox "The number of worksheets in each workbook is " & msg & vbLf & Workbooks.Count & " open workbooks and " & myTotal & " total sheets" End Sub
I would like to write a Sub that will see if a workbook is open and if it is not then open it. I know how to have a macro automatically open a workbook, but I run into problems when the macro runs and tries to open an already opened workbook.
My Splash screen opens a few seconds after the workbook has loaded. Is there a way to make the workbook open minimzed until the the splash screen closes then open properly? What I trying to say is that only the splash screen is visible until it closes.
I want to create a macro that will “open the look in list” and stop so I can pick a file to open. I’ve tried to use “record a macro” and “ctrl-o”, but the record a macro won’t stop until I pick a file or cancel the file list. I also tried to use “o” in the short cut key box
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
I have two workbooks. One is a no-nonsense form interface that my bosses will use to enter safety information. I'll call this workbook "Form". This file is stored locally on each of their computers. The other workbook is stored on a common drive. I'll call it "Master".
When my bosses fill out the Form and click "Submit", the Master file is opened, and certain cells are populated based on information entered in the Form. This is the code I am using to make this happen:
Create a full copy of an open workbook (eg. activeworkbook MyFile.xls) using VBA, with the new copy (eg Book1.xls) open as well ,without having to save a copy first then open it ?
I have built a sub that prompts the user for a folder then opens every workbook in the folder 1 at a time to get stats on the contents of each workbook. Worked like a dam until I ran into an unexpected bug. Some of the users built on open events in their workbooks. ...
Right now my routine inventories workbooks to get formula counts, cell counts, most complex formula, highest value... it does this by looping throught the sheets and the cells. If there is a way of obtaining those stats without opening the workbook I may need to rethink a lot of my work.
way to suppress the code in the target workbook I open through workbooks.open
I did a macro on my mac to transfer a sheet from one workbook to another worbook. It works very well when the destination workbook is open. Therefore I wanted to add some piece of code to check if the destination workbook is open. If not then I wanted the macro to open it before tranfering the sheet. Here is the code I´m using for tranfering the sheet
Sub Transfer_Sluttet() If ActiveSheet.Index <> Sheets.Count Then Application.DisplayAlerts = False Set ws = ActiveSheet Sheets(ws.Index + 1).Delete ws.Move Before:=Workbooks("Sluttet.xls").Sheets("sheet2") 'Moves active sheet to beginning of named workbook. 'Replace Test.xls with the full name of the target workbook you want. Application.DisplayAlerts = True End If End Sub
This is the type of macro I useually use on my pc to check if a workbook is open and if not then open it
If IsWorkbookOpened("Filename.xls", "C:Documents and ..................
how to make a MsgBox open anytime a cell in Column A was double-clicked--and the content of the MsgBox was from the cell in the same row in column Z. I've now realized the double-clicking isn't an ideal solution, as it's easy to click in another cell and mess up all the formulas.
(1) Code that deactivates the "edit directly in cell" option when the workbook is opened.
(2) Code that opens the MsgBox when a cell in Column A is clicked just once (or similarly less fool-proof than double-clicking or right-clicking).
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.
is it possible to write vb code to open the workbook, scroll through everysheet? extract the values from each worksheet?
let's just say, I only know the workbook name, but not the sheets of the name inside. So the vb code could scroll through every worksheet without knowing the worksheet name, only the workbook name(workbook.xls)
This is pretty basic I just don't know what command to use. I have a macro that's supposed to copy data from one workbook to another, it works fine but In the macro it open the other workbook then closes it. I would like the macro to not reopen the second workbook if it is already open (since reopening causes it to lose the newly updated info). I think it can be done with a If command but I don't know which tried the following: If workbooks("M:/database") Is Open but of course 'is open' doesn't work, but can anyone tell me what to use instead.
I have created a spreadsheet some time ago and have been asked to improve on it but I'm rusty with VBA.
I have an automated ordering system that saves each sent order as the date e.g "05-04-2013.xls" but the management team want a graph with the data for the last 4 weeks compared. I have created a seperate workbook called "consumables report.xls" which has a column with the products listed followed by columns "Quantity" and "cost" which is repeated for the 4 weeks of the month.
I want to add a button to prompt the user to choose the saved order e.g "05-04-2013.xls" (all orders saved in same directory) to copy and paste the quantity and cost columns (c8,D69) into "consumables report.xls". I got this to work earlier but it would only paste the formulas and not the values. So I need
A prompt to open workbook Copy range (c8,d69) Close work sheet Paste special .value (c8,D69)
I dont care if it has to open the workbook to copy the data as this will only be used once a month so it dosnt matter how slow the code is.
see my attached sheet cotaining the following questions. in a day report sheet how should i count request matching the crateria of date and other conditions. in a monthly report a heavy conditional sum calculation which make slower sheets how can i make it faster.