Delete Workbook After 3 Attempts
Jan 24, 2008
Now that the code is configured to do what I want, can someone assist me in adding a code that will delete the expired file after the third attempt of the user trying to open an expired file.
Private Sub Workbook_Open()
Dim StartTime#, CurrentTime#
Const TrialPeriod# = 1 '< 1 days trial
Const ObscurePath$ = "C:"
Const ObscureFile$ = "LBFileLog.Log"
'*****************************************
If Dir(ObscurePath & ObscureFile) = Empty Then
StartTime = Format(Now, "#0.#########0")
Open ObscurePath & ObscureFile For Output As #1
Print #1, StartTime....................................
View 10 Replies
ADVERTISEMENT
Mar 25, 2009
Trying to calculate average successful attempts before failure. Have several hundred data points (1=success, 0=failure). A1:A10 = 1 1 1 1 1 0 1 1 1 0
Cell A11 should calculate average attempts between failures for the whole range A1:A10.
View 6 Replies
View Related
Jan 25, 2008
I have a code the requires user to enter a password when prompted, but i like to limit the user from attempting to enter a password to "x" amount of times.
View 10 Replies
View Related
Nov 19, 2006
I notice i could not get into the Vb script password for the excel file given by royUk. May i know what's the password to open it? I need to see it urgently as i am rushing for my current project.
View 5 Replies
View Related
Mar 5, 2008
I'm trying to write what is supposed to be a simple script that looks at a column of usernames (ColumnA) and passwords (ColumnB). I start off by prompting the user to enter their username in an input box and then I want a loop to check this value against the values in Column A. If the username exists, I want to prompt an input box for the password. If the username does not exist I need some kind of limit on the loop to prompt an input box for the user to enter a new username and password that I'll add to the last row of the data table. The loop part is kicking my butt, this is what I have so far...
Sub Main()
Set StartRange = Worksheets("16.10"). Range("A1")
username = InputBox("Please enter your username.", "Enter username", "Jdoe")
i = 1
Do While StartRange.Offset(i, 0).Value <> "username"
i = i + 1
Loop
If StartRange.Offset(i, 0).Value = "username" Then
password = InputBox("Please enter your password.", "Enter password", "password")
End If
End Sub
View 7 Replies
View Related
Jan 31, 2014
I am trying to calculate players ranking based on their weight categories and attempts total, e.g. Category (50kg, 69kg etc..) Rank should be calculated automatically the highest total value of cat. 50kg is 1st second highest is 2nd etc. However, if tow players or more within the same Category have scored same point ranking will be calculated based on Body Weight less comes first and if both have similar weight calculation will be based on Start # first player comes first etc..
Table:
Start #
Name
Body Weight
Team
Category
Total Point
Rank
1
Player #1
49.2
Team #1
50kg
75
View 2 Replies
View Related
Jun 25, 2014
I'm trying to find a way to save a single sheet of an excel workbook and in the same process delete all vba code and shapes from the new single sheet workbook. I was looking around and found this code which does save only the single sheet to a new one sheet workbook but doesn't delete the vba and shape that I have used to assign macros to in the original.
Code:
Sub SaveSheetAsNewBook()
Dim wb As Workbook
Dim InitFileName As String
Dim fileSaveName As String
Dim wshape As Shape
InitFileName = ThisWorkbook.Path & Format(Date, "mm.dd.yy")
[code]....
View 2 Replies
View Related
Jun 2, 2014
I wrote a code in unshared workbook and it works fine. But when i make it shared i get Run-time error '1004' Delete method of worksheet class failed.
The Deleting of worksheet only occurs once (when the new wb is created) so is there i can unshare and share it back when the process is complete?
View 3 Replies
View Related
Jul 13, 2009
I wanted to disable the function "Delete" when right-clicking on worksheets.
I copy paste the following VBA code in every sheet code :
View 10 Replies
View Related
Oct 3, 2008
I have a workbook called wb1 stored in folder C:folder1.
I open the workbook and make some changes to it.
At that point I want to have a macro that will save the workbook with all the changes made in folder C:folder2, under the new name wb2, and somehow delete wb1 from C:folder1.
View 9 Replies
View Related
Apr 20, 2007
I have a problem deleteing a new workbook that has been .Add[ed].
When saving the active workbook as a new workbook the user is prompted for a file name via a userform.
If the new file name is the same as an existing workbook the error handle restarts process ,adding another new workbook.
or if the project number is unique it is saved ...
View 3 Replies
View Related
May 17, 2009
Is it possible for a workbook to delete itself after two weeks or by date since putting in VBA codes?
Or does it have to be active to be able to delete itself.
I'll be going away for a holiday in two weeks (yepeee) and the person who's taking over my place will only use it on first day of my absent.
I do not want others to use my file (of course I'll back it up before I'll go).
View 7 Replies
View Related
Jan 4, 2011
I want to delete all macros from my workbook (so it will work well in Mac 2008). I went to Alt-F11 and deleted all Macros there and check every sheet and found no references. I did all that and when I try to open it in Excel for Mac it says there are still Macros.
How can I ensure my workbook has no macros?
View 9 Replies
View Related
Dec 9, 2011
I am running VBA that will open a new workbook, at the end of that VBA code I have a line of code that reads:
Code:
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
When the code hits those lines it throws a VBA error 400. What do I need to do to have Sheet1 deleted from the "new" workbook?
View 2 Replies
View Related
Oct 10, 2004
if it is possible to delete the current workbook that is open?
I'm thinking of using an add-in to delete the workbook i'm viewing
View 9 Replies
View Related
Aug 13, 2006
Delete All Names in a workbook. Maybe delete names one time?
View 2 Replies
View Related
Nov 27, 2008
I want to create a macro to check through all sheets in an active work book, if a sheet is empty, then delete it?
View 2 Replies
View Related
Nov 11, 2005
How to delete all defined names from a workbook
View 14 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
Feb 20, 2009
ive tried creating a macro/code that when you open a certain workbook it automatically deletes the contents. you see i have a workbook containing 100 sheets that i need to update each week but i have to delete all the contents first, is there a quick way to do this when i open the workbook up?
View 9 Replies
View Related
Mar 2, 2009
my code to loop through sheets in another workbook does not want to work. in This Workbook (SourceWb), I copy the current workbook using SaveCopyAs and then reopen the new workbook. from ThisWorkbook (SourceWb), I am trying to delete any sheet between "First" and "Last" where a specific criteria is not met. so starting from the For Each to get my loop values, where PMs is a list of people's initials:
For Each c In Range("PMs")
If c.Value = "" Then GoTo AfterArrays
View 9 Replies
View Related
Mar 21, 2008
I don't believe this is possible but I've been wrong before.. Is it at all possible to Kill the current workbook using VBA? I " saved as" in another location and do not wish to keep the current workbook.
View 3 Replies
View Related
Apr 15, 2008
Is this possible to set a macro which will delete the file if opened on another computer? Ie say on WB open I want to set a macro that if Environ(“Username”) = “ABCD” then proceed else delete the file permanently from th e other computers machine. If deletion of file is not possible then deletion of sheets or contents of sheets should be deleted. The sheets will be protected. Expecting a solution to delete the file.
View 2 Replies
View Related
May 13, 2008
I have a workbook in which certain shape objects (2 command buttons and a combobox) can be present on a worksheet if another macro has been run. When a worksheet is closed and another opened, or the workbook closed, I need the shapes to be cut if they are present. There are other shapes on the sheet which must not be deleted.
Each shape has a defined name which is the worksheet name followed by DD, GetStats and Rfrsh
I have tried the code below but get 'The item with the specified name was not found' error message if the one or more of the shapes are not present. The code works for any of the specified shapes that are present.
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Range("f5:i17").ClearContents
If Not Sh.Shapes(Sh.Name & "DD") Is Nothing Then Sh.Shapes(Sh.Name & "DD").Cut
If Not Sh.Shapes(Sh.Name & "GetStats") Is Nothing Then Sh.Shapes(Sh.Name & "GetStats").Cut
If Not Sh.Shapes(Sh.Name & "Rfrsh") Is Nothing Then Sh.Shapes(Sh.Name & "Rfrsh").Cut
End Sub
I am sure I am not using the 'If Not' and 'Is Nothing' properly but can't figure out how it should be.
View 5 Replies
View Related
Mar 28, 2014
I have a code which deletes all contents of cell in range except formulas, from sheet 2 to 13. Code works, but I have included toggle button on each sheet to lock/unlock sheets.
If I lock sheets, code doesn't erase cells as needed.
I have figured out code that works for me, but looks like It's not performing quite correct. Although code executes quite quick...
This is my current code :
[Code] .....
How could I rearrange this code to work in proper order ?
View 4 Replies
View Related
May 8, 2014
That particular question has been solved, but now i need it to work with multiple values from combobox.
So for example,
if "Master" is selected in combobox3, it will delete sheets 7, 8
if "CSR" is selected in combobox3, it will delete sheets 1, 8
if "Original IND" is slected in combobox, it will delete sheets 1,7
The current code will work when "master" is selected, however i am getting compile errors when i select "CSR" or "Original IND"
WhenI select CSR, it does create a new wb for me (without sheets 1,8) correctly but i get a Run time error.
Run-time error '-2147417848 (80010108)': Automation error
The object invoked has disconnected from its clients.
When Original IND is selected, i get a compile error and it highlights 'Make the new workbook active newWBK.Activate
View 5 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
Oct 25, 2011
VBA code that would delete ALL other sheets in the workbook except for Sheet "Data".
View 2 Replies
View Related
Sep 8, 2013
I have a worksheet populated with data. I have sorted the data and have dupulicate values in column B,C,D up to H.
I have put in a formula to give me a 1 value in column A where there are duplicates. Is there a way to write a VBA code that will Delete all the rows that have a 1 in column A.
View 4 Replies
View Related
May 30, 2014
I have a VBA script that works great when run each day, as it's intended. But if a user skips a day, we end up with an error when deleting an old worksheet. The old worksheet to be deleted has a date as the sheet name (i.e. "2014-May-23").
We've developed some code to find the most recent FILE if there wasn't one created on the previous business date, but what VBA code can I enter to correctly identify and delete the old, outdated worksheet? My final spreadsheet should contain just two dates worksheets - one each for the past 2 business dates.
Here's a snippet of my current coding:
Code:
Sub Master_3D_Macro()
'
' Master_3D_Macro Macro
'
' Keyboard Shortcut: Ctrl+j
'
Dim CurrDate As Date
Dim Holidays(1 To 9) As Date
[Code] ..........
View 9 Replies
View Related