Prompting User To Delete Worksheet When Opening Workbook

Jul 13, 2012

I am trying to have an operation run when opening the Workbook. The UserForm opens fine, but I get an error when the GoButton_Click sub runs. The error file is not very comprehensive.

The user is promoted to 'Delete' or 'Cancel' before the sheet is deleted. I do want to select 'Delete' for the user, but I'm not sure how to do this.

The error mentioned occurs after the user selects 'Delete'. The error is:

Run-time error '-2147417848 (80010108)':
Automation error

The object envoked has disconnected from its clients.

VB:

Option Explicit
Private Sub UserForm_Initialize()
Me.Choices.List = Array("Choice 1", "Choice 2")
End Sub
Private Sub GoButton_Click()
If Templates = "Choice 1" Then

[Code]....

View 5 Replies


ADVERTISEMENT

Message Box To Pop Up Every 10 Mins Or So Prompting The User To Close The Workbook

Oct 13, 2008

how do i go about setting a message box to pop up every 10 mins or so prompting the user to close the workbook.? i want it to be as irritating as possible! iv'e had a look at ontime but cant get my brain into gear!also don't some of these timers fire even if workbook closed?

View 4 Replies View Related

Prompting User To Open File?

Oct 18, 2011

I have code that prompts the user to open a specific excel file. However, with the following:

Filepath = "..."
name = Application.GetOpenFilename(FileFilter:="Excel Files *.xls* (*.xls*),",)
Workbooks.Open name

the default directory you start out in in the window that prompts the user to select a file is NOT ...

How can I properly assign which directory the user starts in so they need not go through 10 sub-directories everytime they run this code?

View 2 Replies View Related

Prompting User For File Input

Nov 7, 2006

I want to do is prompt the user for an Excel file and then insert it as a new worksheet as sheet 2. Also, if possible I would like the imported file to insert to the right of sheet 1. Anyone know how to do this or at least know some parts of this problem.

View 9 Replies View Related

Prevent A User From Opening Another Workbook

Feb 12, 2009

How can I prevent a user from opening another workbook in an Excel session "from the outside"?

I'm fairly new to VB. I'm developing (in VB 2003) a simple but SECURE Excel environment which will allow a user to update a hidden Master_Records workbook. I need to keep the user's Excel session secure...for example, I've disabled all Excel Toolbars and Command Buttons, effectively preventing the user from doing anything except filling in some cell values and clicking on a few custom buttons in the worksheet. But how can I prevent the user from opening another workbook into the active session from his desktop and introducing some malicious code into the session via that route?

One respondent in another forum (the only one, in fact) suggested that I look into "instantiating workbook level events" so that I can detect when other workbooks are open. I'm not sure what that means, is there someone here who could give me some guidance into that solution?

View 13 Replies View Related

Automatically Sort A Workbook On Opening And Delete Blank Rows?

Jul 4, 2013

I am trying to educate myself in the wonders of Excel (2003) and an struggling somewhat.I have a small project loosely based on a shops stock control and have attached a copy of the workbook -

The user normally only has access to columns B, C and E due to the others being locked and the sheet protected.I would like the sheet to be automatically sorted based on column E each time the workbook is opened.I then need to automatically delete a row once an item in column B has been removed (made blank)

View 3 Replies View Related

Default To Specific Worksheet Upon Opening Workbook?

Nov 22, 2008

I would like the workbook to open to a specific worksheet everytime it is opened regardless of what worksheet it was in when file was saved. Can someone point me in the right direction?

View 2 Replies View Related

User Form - Delete Row On Worksheet Via Combo Box?

Jun 16, 2006

I am trying to figure out how to delete a row on a worksheet via a VBA User Form. I currently have a User Form with a Combo Box that is populated by cells in a named range ("PickCategory...") on a worksheet... I am populating thsi box using this

Private Sub UserForm_Activate()
ComboBox1.List = Worksheets("data").Range("PickCategory...").Value
End Sub

First off, I want to include a lable that will display the contents of the cell to the right of the currently selected entry of the combobox on a label (or textbox). So, whatever entry you select in the combo box, the corredponding value (to the right of it on the worksheet) will appear in the text/label
box. Is there something similar to the VLOOKUP that will work in VBA?

Also, what I want to be able to do is to allow the user to select one of the entries from the combo box (which is already working) and then be able to delete the row of that entry on the worksheet. So, the user selects an entry from the combo box and then clicks a "Delete" command button to delete the row of that entry on the worksheet...

View 6 Replies View Related

Excel 2007 :: ActiveX Controls Command Button Opening Worksheet In Same Workbook

Feb 6, 2014

I have a workbook with two worksheets, "Main" and "Control".

Both of them are with hidden tabs (unchecked "show sheet tabs").

On worksheet "Main" I have command button which opens worksheet "Control".

The assigned makro is: Sheets("Control").Select

The problem is: when I open "Control" and close after that the workbook, the next time when I open the workbook "Control" pops-up instead of "Main" even though I do not save it.

1. I need macro on "Main" which will allow me to open "Control".

2. Regardless I "Save" or "Don't Save" "Control" when selected and workbook is closed, to open the workbook always displaying worksheet "Main".

I use Excel 2007 (at home) & 2010 (at office).

View 1 Replies View Related

Delete Rows That Contain Data From User Defined Dynamic List Within Workbook

Oct 7, 2012

I have a financial dataset which I need to "clean" before manipulating/analysing.

Each row of the data represents a completed transaction and the first step is to delete rows that are done with particular (internal) clients; the client data (the client's name) is in Column D.

Currently, I delete the unwanted data by autofilter and delete (code below), however this means the clients to be deleted are only defined within the code. I would prefer to have a worksheet within the workbook where the user defines the clients by adding or subtracting their name from a list.

I have created a dynamic range for the client list by inserting a Named variable along the lines of "=OFFSET(!$B$3,1,0,COUNTA($B$3:$B$200)-1," which works fine.

However how do I work this list into my code so that it works when new clients are added or deleted?

Current code for deleting unwanted client data:

Sub filterdelete()

Dim LastRow As Long
LastRow = ActiveSheet.UsedRange.Rows.Count

With Range(Range("D1"), Range("D" & LastRow))

[Code] .....

View 2 Replies View Related

Delete Worksheet With VBA From Different Workbook?

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

Opening A File Without Opening A Workbook

Apr 17, 2007

I have a need to open a file from my companies intranet. My current method was to open said file via the method that the recorder gave me. However, I would like ot be able to open a said file without having to start open another workbook.

This is the path:
[url]

So the command is this:
Workbooks.Open [url]

Links are not actual links

So what I need to know. Is how can I open this file without opening a workbook. I haven't been able to use the VB "Open Statement" to open a file and I don't believe that I've been successfull using the Filesystem object either.

View 9 Replies View Related

Opening Files Which Are Already Open By Another User

Feb 27, 2009

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??

Here is the full script -...................

View 9 Replies View Related

Cell Focus When Opening A User Form

May 9, 2007

i would like to retain the focus of the current cell before the user clicks on a button to run a macro (see below) to open a userform...?

userform.show

(the cell focus seems to disapper...after the button is clicked, but does stay on the cell when i run the macro from tools macros...)

View 5 Replies View Related

Excel 2010 :: Macro To Delete Last Line Of Data In Each Worksheet In Workbook?

Apr 24, 2014

I'm trying to create a macro that will look at each worksheet in a workbook and then delete the last line of data on each worksheet. The last row can vary on each worksheet. This is what I have come up with but it is not working. I am on Excel 2010 and Windows 7.

Sub Macro1()
Macro1 Macro
Dim ws As Worksheet

[Code]....

View 2 Replies View Related

Remove Checkbox Ticks From Last Use Upon Opening User Form

Jun 2, 2009

I am simply trying to write a macro or code that will set all the check box values to "False" each time I initiate the User form. So that the user form does not "carry over" check box values from the last time the User form was used.

However I had to make sure I cleared the value from the cell that each control is associated with.(the controlsource in the user form properties.)

View 9 Replies View Related

Opening New Workbook And Pasting Values Into Current Workbook?

May 13, 2014

I am using the below code (i have combined different bits of code which i found on these forums) to open a new workbook, copy all the data in it and paste it into Sheet2 in the active workbook . Also, i want the data to be pasted on the next empty row as there is already data in Sheet2. The data that is being copied and pasted has the same format and it is going to be repeated many times.

The problem i am having is that it is not offsetting the data to the next empty row - i think it is a simple change but i can't seem to get there :s

Also, the code is currently selecting all of the data from the workbook that i open - is there a way i can select all of the data, excluding the first row (the first row contains the headings which i already have in Sheet2 in the active workbook).

[Code].....

View 5 Replies View Related

Copying Data From Userform To Another Workbook Without Opening Second Workbook

May 16, 2014

I have created userform and it works fine. Following code assigned to 'SUBMIT' button in userform - works fine. I am trying to include code where certain data from userform is also copied to workbook2 ( of course without opening it)- as marked in red...below

[Code].....

View 4 Replies View Related

Getting Data Form Workbook Without Opening The Workbook

Apr 6, 2014

Can I search a document without opening it?

If not how do I open a file if not already opened without using "ON ERROR"

View 3 Replies View Related

Opening A Workbook Then Switching Back To First Workbook

Apr 25, 2009

I am trying to make one of my macros open a file then switch back to the orignal file and then running the macro.

here is my

View 11 Replies View Related

Save Data From One Workbook To Another Without Opening Workbook

Mar 1, 2013

I have a spreadsheet that data gets exported to from a software program. There is information such as customer name, part number, inquiry number, etc that I'd like to use to develop a log of all my estimates I create for parts. I'd like excel to take the cells I select and insert them into certain cells in the other workbook and automatically save that workbook. This will create a log of all my estimates where I can then link the full estimate to the log. The information will have to go in the next available row. Is there any way I can accomplish this without having to open the other workbook and save the work book each time?

View 1 Replies View Related

Prevent Workbook Opening If Other Workbook Open & VBE

Aug 29, 2006

how to prevent a workbook from opening if another excel document is open and if a visual basic window is opened.

View 8 Replies View Related

Prompting For Parameter Value Using Macro?

Mar 12, 2014

Last time i got macro from this forum how to import files automatically. I am importing the data from the specific folder.In code itself we are hardcoding that file names.But in that folder i have lot of files is there any option to pass any parameter value.That means each time it will asks for filename(Prompt).Once you give file name it will automatically load the data.

[Code] .....

View 6 Replies View Related

Rename A Sheet By Prompting For A Name?

Jul 24, 2006

I first insert a new sheet and then i want something (inputbox or so) where i can give in the new name of that sheet (i have to do that a lot of times, so i wont do it manually) is there any solution for this thing??

View 2 Replies View Related

Workbook Keeps Opening By Itself?

Jun 12, 2013

I have just added some code to make my workbook close after it has been inactive for 5 minutes...this works fine except it opens itself up again after 5 minutes. If I select 'Enable Macros' it closes immediately and if not, it will stay open.

Here is all of the code I put in for the auto shut down:

ThisWorkbook:

[Code]....

Module 1

[Code] ....

View 3 Replies View Related

Opening In Different Workbook

Jan 6, 2007

I currently have a workbook that, when opened, automatically kicks off a macro (with a call from the Workbook_Open event in ThisWorkbook). I was to run that same called macro from a custom button that I put on a toolbar in Excel itself...which is pretty straight forward. However, when I do this, the macro kicks off twice...once from the button and once because the called macro's workbook opens and kicks off the macro with the Workbook_Open event.

So, what I was thinking was...is there a way to tell if a workbook is being opened by another workbook (by calling it's macro) or whether is was opened "normally (manually)"?

View 9 Replies View Related

Workbook Opening Twice

Nov 9, 2006

My friend emailed me a workbook. When she or I open the workbook, it opens two instances of it. Is there an option in excel that is causing it to do this? I need to send this a client and I do not want this to happen on their side.

View 6 Replies View Related

Without Prompting For Any Macros Security Message

Aug 28, 2008

i want my application which i build though VBA in excel run on every computer without prompting for any Macros security message so is there any solution?

View 9 Replies View Related

Always Opening On The Same Worksheet

Jul 8, 2006

I have a workbook with loads of various worksheets,, which is shared between a group of us.

What i want is that each time the workbook is opened it always starts on the same worksheet called 'main'.

View 5 Replies View Related

Opening Workbook On Sheet 1

Apr 23, 2014

I have a workbook that consists of 3 sheets, it's a template I use. Once I am done filling out sheet 3, I save as a new workbook. When I have to go back to the template workbook it always opens on sheet 3. Is there anyway that once I open the template workbook it will open on sheet 1?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved