Activating New Workbook That Hasn't Been Saved As Yet
Apr 3, 2014
I am busy with code that filters and copies from a "source file" using dialogue to choose criteria than adds a workbook and pastes filtered information. I than go back to "source file" and do second filter. My question is this newly added workbook changed from book1 to book2 etc everytime the user will run the macro. How do I go about activating the workbook for second and third paste without it being saved?
Here is name code:
[B]Workbooks.Open ("C:Documents and Settingsabek276DesktopSource File.xlsx")
Options = InputBox(Prompt:="Scheme Code", Title:="Options")
Options1 = InputBox(Prompt:="Scheme Code", Title:="Options")
Options2 = InputBox(Prompt:="Scheme Code", Title:="Options")
[Code].....
View 7 Replies
ADVERTISEMENT
Jun 4, 2007
I'm trying to simplify a formula that I'm using in a spreadsheet that's being used mostly in Excel 2000.
2 reasons I'm doing this:
1) It doesn't work if the worksheet hasn't been saved yet.
2) It's ugly
=DATE(YEAR(DATEVALUE(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,3) & " 20" & MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+5,2))),MONTH(DATEVALUE(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,3) & " 20" & MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+5,2)))+1,0)
The formula returns the last day of the month of the name of the sheet. For example, if the sheet is names "Mar 07", it returns 3/31/07. (yeah, when the 2100 issue becomes a big deal, I'm not going to be ready but I have 92 years to think about it)
Even if I can't make it prettier, does anyone have a way to get the sheet name into a formula without VBA Code in a file that hasn't been saved.
View 9 Replies
View Related
Apr 24, 2008
I want to copy from a Workbook into an Excel Worksheet and close the Workbook.
HTML Workbooks.Open (stgPosition)
'Range("A1:I150").Select
'Selection.Copy
'Windows("Symbol Assembler.xls").Activate
'Sheets("Sheet1").Select
'Range("O1").Select
'ActiveSheet.Paste
Workbooks (stgPosition).Activate
Application.CutCopyMode = False
ActiveWindow.Close
When the Debug gets to "Workbooks (stgPosition).Activate", I get an error message:
Routine error "9" Subscript out of range.
View 9 Replies
View Related
Sep 27, 2006
I have multiple workbooks open, and would like to activate a workbook whose name has a certain string in it. How would I do this with VBA?
View 3 Replies
View Related
Jul 17, 2009
This has been kicked around for some time and so far there isn't an answer.
I want to approach it a little different this time.
My users can have let's say 5 separate instances of Excel open.
The user clicks on a macro to open a workbook and I have programmed a message that says "This File Is Alredy Open".
The code I used is: ....
View 6 Replies
View Related
May 15, 2009
I have my VBA Codes set in a workbook (Production) that my supervisors open to calculate production. So when they open the workbook (Production) I have a button that they push that starts the code however I need to put something in that activates the other open workbook, The problem is that the name of the workbook that they run the code on can change.
View 2 Replies
View Related
Dec 21, 2009
An Excel file is e-mailed to my company for all the credit card transactions in a given day. Because we manage many stores and each store is a different legal entity and a different fiscal year ending, I need my macro to sort the information and separate the transaction by store and by fiscal year end. I just hit my first block.
I need to open a workbook off the server to grab information for a vlookup formula. I can get the workbook open, but I can't get back to the original workbook or find a way to reactivate it. Because the macro is going to be saved in the "personal" workbook, I can't use the "thisworkbook.activate" code. Also the workbook name and tab name that is emailed to me will always be different so I can't use other solutions that I've seen posted.
View 2 Replies
View Related
Aug 1, 2014
For some reason I'm consistently getting an error in the following line:
Code:
Public wkbk1 As Workbook
Public shtInput As Worksheet
Public i As Integer, iPass as Integer
[Code]....
View 6 Replies
View Related
May 27, 2006
Need VBA code to save column J of open workbook called LmbcAcctsPayable.xls, Sheet1, to same workbook & sheet called LmbcAcctsPayable.xls, Sheet1, when save is not selected.
Reason: The workbook is usually not saved because it is more of a templet with names in column A. Column J is updated with a date when a row is used so I need the column J to copy automatically to the blank templet when exiting without saving (using ThisWorkbook.Save = True in Auto_Close). That way, rows not being used for a long period of time can be periodically eleminated.
View 3 Replies
View Related
Oct 15, 2009
I would like to execute a sub when the workbook is saved, what is the procedure for this.
View 3 Replies
View Related
May 13, 2008
I want the excel spreadsheet to "BE Protected" in standard form, and only be "Unprotected" when macros are enabled -- BUT DONT JUMP TO CONCLUSIONS, hear me out, it gets deeper than that
If the user does not enable macros, I want the book to be protected. If they do enable macros, it becomes unprotected.... (On load is good enough, no need to be real-time)..... But, they can save the book, so it would no longer be protected , which is where my question comes in ...
I could use the -unprotect "password"- on load when macros are enabled but this will only work if the spreadsheet was originally protected and is never saved again. This is a problem because this workbook will be given to others and will be saved time and time again.
So, I had a vision :-) .... function 'before save' , protect the sheet using -protect "password"- , allow the sheet to save, and then unprotect back using 'unprotect "password"' so you can continue using - BUT, the problem with this is now I have created an endless loop in theory, because after it unprotects it would want to re-save again because it changed
View 12 Replies
View Related
Nov 25, 2009
I have a workbook that I constantly am improving with new macros and VB routines. I sometimes have two versions available for use at the same time. I would like to create a macro or routine that will tell me if the workbook has been saved. A simple cell color change to indicate I've saved would be fine. Also, if I DO save the file and the cell color changes to indicate I have saved, I would like the cell color to change back if any change is made to the workbook. This way I will always know if I need to save or not to keep latest changes.
View 3 Replies
View Related
Nov 15, 2011
I currently have the code below that closes all but 1 sheet in my workbook called Main
Is there anyway i can clear a range of cells on a couple of sheets within the workbook when save is pressed?
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
For a = 1 To Sheets.Count
If Sheets(a).Name "Main" Then Sheets(a).Visible = 2
Next a
End Sub
View 4 Replies
View Related
Sep 7, 2007
I am looking for a macro that will run on worksheet activation. it needs to run only if the file had been saved from the previous week. would something like this work?
Private Sub Worksheet_Activate()
If application.worksheet.lastsaved = msolastweek Then
range("RANGE").clearcontents
End If
End Sub
View 7 Replies
View Related
Apr 25, 2008
I've designed a performance indicator (PI) recorder for up to 12 users, it has a userform allowing the users to input their data and a button to save the data and unload the user form. the data is saved using the following
Dim NextRow As Integer
On Error Resume Next 'skips line if workbook is not open
ActiveWorkbook. Sheets("DATA").Activate 'sets the "data" worksheets as active
NextRow = Worksheets("DATA"). Range("A" & Rows.Count).End(xlUp).Row + 1 ' finds the next empty row
With Worksheets("DATA").Range("A" & NextRow) 'inserts the data from the user form
there follows a series of offsets to slot the data into the correct column,
then this code to save the workbook
ActiveWorkbook.Sheets("reports").Activate
Application.DisplayAlerts = False ' suppress overwrite warning message
ActiveWorkbook.SaveAs "MY PATH"
CreateBackup=False
Application.DisplayAlerts = True
MsgBox "Spread sheet Saved"
The problem I'm having is that when the user then closes the excel application there is a conflict between the users 'saves' i.e. one ultimately will overwrite the other. is there a way round this ?? (this is in EXCEL 2000)
View 2 Replies
View Related
Oct 15, 2008
I have working code to unhide specific worksheets from a large number of hidden worksheets and would like to be able to delete all the hidden sheets when the workbook is saved or maybe have a button to delete all the hidden (un-needed) worksheets beside the selection drop-down menu, so that only the selected sheets are saved.
View 4 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
Jan 8, 2007
I have one workbook named "Data Master" with numerous worksheets... all sheets are named with the following 6 digit format, eg. 005001, 005024, 005133, 005456, 005763, etc.
I have another directory with files each beginning with the particular 6 digit cost centre number.
I was hoping to have a macro that will... for each worksheet in "Data Master" check a specified directory containing the cost centre files, for the file beginning with the relevant worksheet's 6 digit cost centre number... and simply paste a copy of the worksheet in "Data Master" to the end of the existing sheets in the cost centre file.
View 9 Replies
View Related
May 12, 2008
I have created a template with a form. Now I'm using (the code is in ThisWorkbook)
Sub Workbook_Open()
frmMyForm.show
End Sub
This runs the form also when opening the template or a saved workbook based on the template. I want the form to run only when creating a new workbook based on the template. How do I do?
View 3 Replies
View Related
Jan 19, 2010
Yet some more changes to a badge log, have worked out most of it but am having problem selecting the right row. The problem I'm having is finding the badge number (set in column J) and then finding the row that doesn't have the check out date (column B).
I know this code will find the first entry in the data sheet, I just can't figure out how to set it up to find the badge number that hasn't been checked in yet.
View 13 Replies
View Related
May 3, 2013
When I open any saved Excel file the saved file opens along with a blank workbook titled "Book 1". How can I make it so when I open any saved Excel file it only opens the file I want and not a new workbook every time?
View 2 Replies
View Related
Mar 16, 2004
Is there any way of creating a log that logs the last user that saved the workbook including the date and time. I would like the log to be a sheet hidden in the workbook. Not many people will be saving the workbook.
View 9 Replies
View Related
Dec 12, 2012
I have numerous spreadsheets that I need to open and unhide a sheet, that has XML data stored in cell A1. What I need to do is copy that data in cell A1 and paste it into a text document and save that as an XML file saved as the XLS workbook name with a date stamp.
I'm running into many issues, the main issue is the saving as current file name, and the formatting of the text/XML file.
Here is my current code, which doesn't reference the current file name and is just very generic. Once I get the saving as file-name correct and the formatting of the xml file correct, I will work on it a bit more.
Code:
Sub Test()
Dim Rng As Range
Dim wb As Workbook
Set Rng = Range("A1:A2")
Set wb = Workbooks.Add
With wb
Rng.Copy
[code]....
View 4 Replies
View Related
Jun 8, 2006
Below is code I use to try to 1. call a sub that take the users to a specified location on a specified shhet, 2. one to remember user menu set up, 3. one to remove tool bars, 4. one to set up menus for operation of my program and code to activate two addins required by my spreadsheet program.
If neither of the analysis addins are selected prior to opening the spreadsheet, when the spreadsheet is opened the appears to work properly except that the 'Start' sub is not initiated. If the spreadsheet is saved, closed and reopened it all works perfectly.
However if both of the analysis addins are selected prior to opening the spreadsheet for the first time all code appears rto work perfectly.
Private Sub Workbook_Open()
Application. ScreenUpdating = False
Call Opening_Screen
Call Toolbars_Record_List ' writes to sheet cbars the names of command bars to recall on leaving
Call Toolbars_Remove
Call Endusermode
Application.AddIns("Analysis ToolPak").Installed = True
Application.AddIns("Analysis ToolPak - VBA").Installed = True
Call Start
Application.ScreenUpdating = True
'UsrFrm_CopyRightMessage.Show
End Sub
View 9 Replies
View Related
Dec 26, 2008
I have the following function: ..
View 7 Replies
View Related
Nov 7, 2008
I have an addin "My Menu" that runs several routines. These routine require the sheet to be converted to text "Sub text ()" no problem so far. But I want to warn the user that the sheet is about to be converted to text.
Is there a VBA way of displaying a message box when "My Menu" is clicked on that says "Sheet will be converted to Text OK ?"
View 9 Replies
View Related
Jul 19, 2006
I am trying to activate a Dynamic Hyperlink in IE. Each time a user starts a new session, a single parameter in the URL changes. Is there a way to search the page, identify the preferred link, and activate it without knowing the full hyperlink address?
The hyperlink is as follows: [url]
The parameter after "unitchange" is what changes from session to session.
View 9 Replies
View Related
Aug 2, 2006
I am encountering a strange situation with my Excel 2000. I have a public function, in a module in the VBA project associated with my workbook. But I'm not calling it from nowhere inside the code, or from other macros - it is not being referred anywhere in the workbook. Yet, after I make a slight change in code and not save my changes, when I return to the workbook and select a value from any cell with a validation-list (regardless of the sheet where it resides), that particular function is being executed!
View 9 Replies
View Related
Feb 2, 2007
I have made a dialog box open using VBA to select some file,
Function FSel()
filetoopen = Application. GetOpenFilename("Document Files (*.xls), *.xls", 1)
Workbooks.Open Filename:=filetoopen
End Function
I need to activate the sheet which is selected in that string "filetoopen".I am not getting the way to do this ,the normal Windows(" " ).Activate is not working with variable as input.
I am placing the funcation Fsel in a loop so each time it asks for the file to open which is not proper,so i wanted to activate sheet .
View 9 Replies
View Related
Mar 23, 2007
All code is called from another workbook
This fails on the second line with a type 9 error, ie worksheet not found
Workbooks("RENT_EXPLANATION.xls").Activate
Worksheets("Rent change details").Activate
This works:
Workbooks("RENT_EXPLANATION.xls").Activate
Workbooks("RENT_EXPLANATION.xls").Worksheets("Rent change details").Activate
Surely both should work since the default qualifier for the worksheets object is the activeworkbook? This only fails in Excel 2003, in the same app. in Excel 2000 it works.
View 4 Replies
View Related