Create A Simple Macro To Open A Second Workbook?
Jan 31, 2014
I am trying to create a simple macro to open a second workbook if the value in a cell in the current workbook is 'x' or if 'y' do nothing.
Basically I have a simple sales ledger, one column has a yes/no for whether or not an invoice is paid if no I want to open a second workbook 'debtors' so that I can manually input the details. I'm sure this is a very simple proceedure but I can't seem to crack it.
View 2 Replies
ADVERTISEMENT
Aug 24, 2009
I am using excel 2007 for database of a large e-commerce site.
I am creating search-able attributes from keywords found in description, title and meta-data columns.
I am using the following function in "column X" to search 4 columns (see formula) for specific music styles.
View 6 Replies
View Related
Jul 30, 2009
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 ?
View 9 Replies
View Related
Sep 27, 2006
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 ..................
View 3 Replies
View Related
Dec 7, 2012
Here's my macro:
Code:
Sub CopyRow()'
'Copies row to new sheet, highlights it, marks column 'A' as copied.
'
Dim cCell As Range
Set cCell = Selection.Cells(1, 1)
Selection.Copy
Sheets("Sheet2").Select
Rows("2:2").Select
[Code] .....
Is it possible to modify it to paste into a different workbook called c:filesDestination.xlsm, instead of the existing workbook (Source.xlsm)? The destination sheet name is the same (Sheet2). It's OK if both workbooks are open at the same time.
View 2 Replies
View Related
Nov 8, 2007
Is there a way that I can make an excel sheet and save it in a way that when it's opened the person JUST sees the cells in a really simple window...
Not sure if I'm confusing people in how I explain this... but basically I don't want it to show the scroll bars, the A B C D etc and 1 2 3 4 etc, the tool bars... etc. JUST the specified cells in a sheet.
View 9 Replies
View Related
Apr 8, 2013
Is there a way to run a macro in an open workbook when the workbook becomes activated or deactivated? So if I have workbook A open with a macro in it and workbook B open as well, can I have the macro run on workbook A when that becomes the workbook I see on my screen?
View 2 Replies
View Related
Jul 26, 2009
I have recorded a macro which will create the border for me when the file is opened, but it turned out too long. if someone can show me how to reduce the codeing. I have the attached file.
Range A5 to E20 thin Border all sides and thick border allround (16 rows)
Range A21 to E36 thin border all sides and thick border allround (16 rows)
end range is A356.
View 5 Replies
View Related
Mar 31, 2009
I have a spreadsheet which has all the names of trips from a warehouse, the day that they operate (1,2,3 etc) and the job line allocated to each trip. It looks something like that:
A B C
DAYTRIPCUST
I would like to create a macro that will be creating 7 new workbooks and then in those workbooks as many sheets as the trips. In these sheets, the customers should be displayed.
How do I write it? I could not find how to have a "dynamic choice" in the macro. I.e. not to have the criteria as "1", "trips1" but to choose from the range of inputs that are available.
View 9 Replies
View Related
Apr 6, 2013
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.
week 1 week 2 week 3 week 4
Product
quantity
cost
quantity
cost
cost
quantity
cost
1
2
3
4
5
6
7
8
View 7 Replies
View Related
Apr 19, 2008
I have downloaded the sample file at the bottom of the 'Contextures' webpage that explaines how to create a simple userform...
[url]
at the very bottom there is a 'Download the sample file' link
This simple form alows the user to input 4 bits of data, PartID, Location,Date and Qty. This data is saved in another part of the worksheet called 'Partsdata'
What I want is somehow for the user to be able to seach for a PartID from the list in the Partsdata worksheet. When this PartId is found, display the userform in a way that the data relating to that PartID can be edited and then re-saved when the user clicks on the 'add this part' button.
For example....
Msg Box or user form dispalyed stating...."Enter PartID to edit"
a search of the PartID column (columnA) in PartsData worksheet is carried out and when the matching PartID is found the corresponding information is displayed in a user form that can be edited by the user.
Once the user has made any changes to the data shown, the user clicks on the 'Add this part' button and the new data is re-saved using the same partid reference.
View 9 Replies
View Related
Dec 17, 2013
I am trying to create a simple dash board using only Excel and no VBA. What I am trying to do is I want to create dependent drop downs and link up drops downs that will pull out the required data individually or with combination of those two. For example, let's say
A column has Dates of transaction,
B column has Item name
C column has Units
D column has Month name
E column has Shifts (Morning or Evening)
I am trying to make a dash board that will pull total Sum of individual items based on
Only Date wise
Datewise + shift wise
Month wise
monthwise + shift wise
I managed to create drop down list for dates, months, and shifts but i dont know the way how to link the individual drop down lists together to pull the data based on the selection. which function i should use here and how?
View 5 Replies
View Related
Dec 4, 2012
I have a # of games played column (Column A), a # of games won column (Column B), and a number of games lost column (Column C).
I'm trying to make it so Column C automatically enters the number when I put in the number in Column B.
Example:
Games Played........Win........Loss
1.........................1...........0
2.........................1...........1
3.........................1...........2
4.........................2...........2
For the fifth game played, if I won it, how do i make the 2 to automatically enter into the loss column when I put in the number 3 in the win column?
View 2 Replies
View Related
Nov 17, 2006
I created folder on my desktop to hold various documents. I have master excel document which contains forms and command buttons that open documents from same folder. Is there a way to change code instead of having full file path to specify current directory. I'm worried that if I move this folder to another location then my open file button will not work since location is changed.
Also when I open with command button word document, I have a button on word document to close. I can close document but word application is still active. Can I close word application with the document at the sam time. This is the code I'm using: "ActiveWindow.Close"
View 3 Replies
View Related
Apr 29, 2009
I currently have a macro set up to run once a workbook is saved/ closed. This works fine unless tehre is more than one workbook open. When I try it with more than 1 different workbook open I get a run error.
My code begins:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
and then performs the macro. I don't really want to specify the filename as this is liable to change. Is there anyway of adding a "this workbook" command to the text string, and if so where would it go?
View 10 Replies
View Related
Dec 16, 2011
if workbook("Result") is not open then
add new workbook and name it "Result + date and time"
else activate workbook "Result"
View 3 Replies
View Related
Nov 14, 2008
I found an outlook plugin that saves any incoming emails as text. It also has an option to run an exe or bat file on saveing the email to text. I have a macro in a worksheet that will process the email to a database and send out a response.
What I am trying to figure out is how to run the macro in the worksheet whenever an incoming email is saved. So I have the 2 components that I need, I just need to tie them together so that everything is automated.
Does anyone know how to achieve this? Can I use a batch file to open an excel workbook and run a macro? Or can I create a standalone macro (outside of excel) that can open the excel file and run the macro.
View 3 Replies
View Related
Jun 30, 2009
i have a button on my workbook1 that opens another workbook (lets call it workbook2) and automatically runs a macro on opening it. Once opened i have a button on workbook2 to close itself. I then go back to see workbook1. This all works but then when i click on the button to open the workbook2 again it opens but the macro does not run.
View 4 Replies
View Related
May 29, 2007
I'm trying to get a Workbook.Open macro to work. I"m using the exact name for the location. For example:
Workbooks.Open ("O:AdministrationPM Weekly's2007PMWeeklyWE")
My other locations are working fine. For example I am using:
Workbooks.Open ("O:AdministrationDCS Week EndingStats"
View 9 Replies
View Related
Jan 15, 2008
The problem is that LastRow does not seem to look in the workbook that the macro has open, and always returns a value of 1. If I place the sheet that i want to run the macro on, in the workbook that contains the macro there is no problem. What do I need to do to fix this.
LoopCount = Sheets("Dates").Range("A" & Rows.Count).End(xlUp).Row
rng = 2
i = 1
Do
Selection.AutoFilter Field:=7, Criteria1:="=" & Sheets("Dates").Range("A" & rng), Operator:=xlAnd
z = Range("B" & Rows.Count).End(xlUp).Row
For y = 2 To z
If Rows(y).Hidden = False Then Exit For
Next y
MsgBox y
MsgBox z
Range("H" & z).Formula = "=Countif($A$" & y & ":$A$" & z & ",A" & z & ")"
Range("H" & z).Copy Destination:=Range("H" & y & ":H" & z)
rng = rng + 1
i = i + 1
Loop Until i = LoopCount
View 9 Replies
View Related
Nov 17, 2006
Trying to Figure out how to open another Excel (based on an template). From Dok1 I start A Macro To Open Doc2.xlt (using Workbooks.Add). Then I Would Like To Write to a Cell But I end Up Writing To The Cells Of Dok1 Even Though It's Dok2 That Is Visable and Activated. I allso do this with word, I have no problems there (Excel to Word) But there i'm using Bookmarks To transfer data. As far as i know , you can't use bookmarks in excel.
View 4 Replies
View Related
Jun 21, 2007
I am looking to check if its open, if it is, then copy the row, if not, then close it.
I am still new to vb, so learning as I go, but looked at many other posts, and there are so many ways i have seen to open one, I'm not sure which is the best, and none that I have seen show me if they check if its open.
View 9 Replies
View Related
Jul 25, 2007
I have a workbook with the following
Sub Workbook_Open()
Sheets("Occ-Rent-Concess Worksheet").Select
ActiveSheet.Unprotect Password:="pass"
ActiveSheet.Select
Cells.Locked = True
ActiveSheet.Protect Password:="pass"
pass:
UserName = InputBox("Enter Log On Name to Continue..............................................
This code opens a msgbox that asks for a password and then unlocks certain cells based on what the password is. I have 140 of these workbooks. I need to be able to open them all and change one cell in each file, save it and close. I've gotten the macro written to open, change and save the files, but I am still having to type the 'password' 140 times. Is there a way to bypass it?
View 4 Replies
View Related
May 12, 2008
I am trying to write code to open a new (blank) workbook while in an existing workbook (I am then going to pass data between the two which is easy). When I try to record the code to get the syntax for opening a new workbook it will not record any code. I also need to name the new workbook based on text in a cell in the existing workbook. I just saw before posting this that the code;
workbooks.add
will open a new workbook now I just need to name the new workbook based on text in my existing workbook.
View 2 Replies
View Related
Jul 20, 2003
Is it possible to use a macro to:
1. Open Excel from the Desktop
2. Open a workbook
3. Execute a macro from this workbook
If so, how can it be done, specially point 1?
View 9 Replies
View Related
Mar 14, 2014
I need to have a workbook (all of them in a folder, ideally) refresh in the middle of the night. The file is large so the refresh takes a full minute. I know I can't auto refresh a closed workbook (pretty sure anyway), and I can't leave the workbook open for various reasons.
So I'm thinking I could have a macro in an open excel (it kicks off on open) that will open a particular workbook elsewhere (the one I need refreshed), open it, refresh it and close/save it. Ideally it would do this for the entire group of workbooks in the folder but I'd be happy to start with just one. I would like to set it to occur every twelve hours (so at midnight, say, this would occur - I would just have to leave the workbook with the macro in it open on a computer so that it runs and completes this task every night).
View 7 Replies
View Related
Nov 13, 2011
I am relatively new to writing script in excel. I have a 34 sheet workbook that includes inputs, intermediate calculations and then reporting outputs.
I am trying to write macros to do the following
1. On opening - all sheets except a contents page (with macro buttons on it) are hidden
2. One of the macros on this page will unhide all sheets (i.e. a 'developer mode')
3. One of the macros will unhide all relevant input and reporting sheets (i.e. a 'user mode')
I originally set up macros to run on workbook opening that hid all sheets except the contents page and this was working but ran into trouble when I opened up the 'User Mode' saved my changes and exited - the macro didnt work when I went to open again (I think because some of the sheets were visible and some werent and it was trying to hide sheets that were already hidden).
To counter this I set up a macro that made all worksheets visible on workbook closing - this works except I keep getting a 'Save' prompt from excel because the location of selected cells (or the sheet I am viewing) has changed from last opening (not to mention the inputs may change).
I am thinking the best way to fix this as follows:
1. Keep the opening macro the same
2. Keep the user/developer macros the same
3. On closing - develop a macro that unhides all sheets after the user has selected whether or not they have made changes to the sheet in a pop up message box - if they choose yes then they are prompted to save as and then the macro to hide all sheets runs on the new version - if they choose no then they are not prompted to save the document (i.e. next time they open they will be opening back at the contents page with the same inputs they started with in the previous session).
View 1 Replies
View Related
Nov 17, 2011
I have a macro in a workbook template,that when the workbook is open it populates a cell with the date and time such as 111711.507. This becomes the contract number for this workbook.. They complete the form or workbook and save it. The next time they open the saved workbook the macro runs and changes the contract number to a new number. I want to disable the macro on the saved workbook from changing the number.
View 2 Replies
View Related
Sep 5, 2012
create this macro.
I am trying here is,
I have open workbook with command button, by pressing it it should do followings
Copy Range ("A1 : C20")
Open a closed workbook
Add Sheet with date format
Paste the range in Created sheet in A1 to C20 column.
View 4 Replies
View Related
Oct 9, 2009
I currently have a macro that goes into a specified folder and opens all the files within that folder. This works great for me, but if i have to change the location of the folder i need go into the macro and change the destination code.
I was hoping to let other people use this, but not necessarily people who would be able to go in and manually change the folder location. What i was wondering is if there is a function out there which would pop up a browse box which would allow the user to specify the folder location in which the files are kept? This would mean any user could use the tool to open the files without having to have the spreadsheet setup up on their machine.
View 9 Replies
View Related