Clicking Cancel On InputBox To Delete Newly Created Sheet

Mar 4, 2010

I created with code to copy a template, hide that template, and pop up a box to rename the copy, I noticed she clicked "Cancel" on the InputBox. When she did, she received an error (400). What I would like to do is when the "Cancel" button is clicked, the newly created copy would be deleted. Is this possible?

Here is the code for my full "Create New Project" sheet procedure:


Sub CreateNewProject()
'This code will copy the Project Data sheet, hide it and then
'rename the new copy to the MSA number. Code also prompts user for
'MSA Number and fills that in on the form.
Dim RenameSheet As String
Dim oSheet As Worksheet
With Sheets("Project Data")
.Visible = -1
.Copy After:=Sheets("FHWA Quarterly Report")
End With...............

View 9 Replies


ADVERTISEMENT

Newly Created Tab Names Placed As Hyperlink On Content Sheet

May 11, 2006

I attach an example worksheet with the code I have thus far.

In my workbook I have other sheets, one of which changes and updates a specific one each time a new client's data is entered on said other sheet. Because I want to save the specific client's data and not lose it when another client's stuff is entered on this other sheet, I copy the sheet where the data is summarised (I called this sheet "Sheet to Copy From") to a newly inserted sheet and use Paste Special, Values Only to change all functions /f ormulae / Links ect to values.

I then change the name of the sheet to the name of the client.

I then use this sheet name / cell value to polulate a range on another sheet (Next Empty Cell) as a Hyperlink to the newly created sheet above. This sheet I called "Table of Contents".

how to code the hyperlink. Using Macro Recorder uses the specific case's names, but the Tab name to be used as Hyperlink value will always be the name of a new client,

View 8 Replies View Related

Paste Into Newly Created Tab

Jul 21, 2009

I originally posted this in the "Excel New Users forum" - i guess that was an error, but I'm very new (second post) and very new to VBA in general - so please be gentle!!

I've created a macro which opens a workbook, creates and renames a new worksheet, and moves it to the end of the workbook.

I then need to paste into this new worksheet a selection from another workbook.

How would I specify in the code that the selection needs to be pasted into the newly created tab?

View 12 Replies View Related

Paste Special Into Newly Created Tab

Jul 21, 2009

I've created a macro which opens a workbook, creates and renames a new worksheet, and moves it to the end of the workbook.

I then need to paste into this new worksheet a selection from another workbook.

How would I specify in the code that the selection needs to be pasted into the newly created tab?

The code I have so far is as follows:

Worksheets.Add.Name = Workbooks("SHEET1").Worksheets("monthly report").[p1]

ActiveSheet.Move _
After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)

Windows("SHEET1.xls").Activate
Range("A1:N23").Select
Selection.Copy

However, I got a subscript out of range error pointing at the line of
Worksheets.Add.Name = .Worksheets("monthly report").[p1]

View 9 Replies View Related

Newly Created File Not Saving At The Given Location

Jul 1, 2014

I have an issue with saving the file at the desired location below is the code i have currently used . I have given the destination as "D:New folder". The new file does get saved at location "D:" but not inside the "D:New folder", instead names the file as "New folder".

View 3 Replies View Related

Saving Workbook In Newly Created Directory

Jun 18, 2009

I am trying to have the user hit a button and save the workbook in a newly created directory. Currently it creates the new workbook and the new directory with the correct names, however the workbook is not in the newly created directory.

View 5 Replies View Related

VBA / Creating And Attaching New Sub To Newly Created ActiveX Control?

Jun 2, 2014

After programmatically creating a new activex checkbox, I want to create a sub for it's click event. I have given the object a name, and fortunately the code for it's click event is a one-line call of another sub, but how?

The sub would look like the following except be named after the new control (obviously), and yes, it is just the number in the name that changes:

[Code] .........

View 2 Replies View Related

Copy Paste Cells To Newly Created Workbook

Aug 9, 2008

My code in the first workbook generates a new workbook with a variable in the filename, then copies the cells from the first workbook to the newly created workbook. This code is working properly when used in a draft worksheet I use for testing. As soon as I put it in the master file, an error message pops up "Runtime error 1004 : select method of range class failed". Then the debug sends me to the line " Cells.Select ". What should I be looking for, why does my code work on one file but when i put it in another one it doesn't ?

Private Sub CommandButton1_Click()
Dim line_counter As Long
Dim prm_line_value As Boolean
prm_line_value = False
Do
prm_line_value = Sheets("Rate").Cells(1 + line_counter, 1).Value
line_counter = line_counter + 1
Loop Until prm_line_value = False
line_counter = line_counter - 1
Dim Wk As Workbook
Dim number_of_new_wb_needed As Integer
If line_counter < 5000 Then.....................

View 3 Replies View Related

Test For InputBox 'Cancel'

Jan 19, 2003

After an InputBox statement, how do I test to see if user pressed "Cancel" and if so, exit the Sub?

View 9 Replies View Related

Application InputBox Cancel

Feb 24, 2010

Application.InputBox ("test")
I get a cancel button, I want this to show a message and then exit the program.

My entire porgram is in one Sub.

View 9 Replies View Related

Determine Cancel On InputBox

May 29, 2007

I am facing a problem while validating an Inputbox actually the issue is that when user press Cancel button on Input box it returns a empty string and also when user does not enters anything in Input box and pressess ok than too a Empty string is returned . Than how we will apply the following conditions :

1) If user does not enter anyting in InputBox and pressess OK than a msgBox should appear saying that "Uhav entered empty string and than looping back to inputbox"

2) If user pressess Cancel procedure should End


Sub try()

Dim Path
Path = InputBox("Specify Path" , "Report Path")

If Path = "" Then

' Issue comes here becuse anyways code reahes here if user either lefts the Inputbox empty and presses ok OR user pressess cancel as i need to show different actions for 'different conditions

End If

End Sub

View 9 Replies View Related

Insert Function To Cancel Button In InputBox

May 13, 2014

I have the code below. That code call some InputBoxes in sequence, that be filled with correctly information like name, cell phone, date of purchase, etc. (sheet is in Portuguese)

But I want to give a function for 'Cancel' Button, because actually if we click on cancel Button, the macro skip to the next inputbox.

I want to click in Cancel Button, and Exit Sub, I used this Tip for example

[Code] ....

But if we do not fill the Text field, the Macro Exit Sub Too

Some fields are optional, so for this i search for a solution

Click in Cancel Button and Exit Sub

[Code] ....

View 5 Replies View Related

InputBox / Ok And Cancel Button - Protect And Unprotect

May 25, 2014

I have this macro code that can protect and unprotect, It will show the input box and ask for a password. my problem is when I choose cancel, it still protect the file, the same thing with my unprotect code. here is my code below

Protect Code :

[Code]...

Unprotect Code :

[Code]...

View 5 Replies View Related

Macro Delete The Sheet And A New Sheet Created

Jan 1, 2008

I have a sheet that I will activate by clicking on the tab.
In that sheet I have a code Worksheet_Activate / Call Summary / End sub

The problem is that the macro Summary this sheet get deleted and a new sheet
created,so I can use only one time this Worksheet_Activate.

View 9 Replies View Related

Excel 2010 :: Creating Multiple Tables In VBA And Referring To Newly Created Tables?

Jul 1, 2013

Using Excel 2010. I'm writing a macro that sets up a workbook to be used for estimating at the beginning of a project. In the code I need to create multiple tables (formerly known as "lists") in the workbook. Then later in the code I need to refer back to those newly created tables. Currently, the code that creates the table is part of a loop that creates the table on many different worksheets. The problem of course, is that I have to name the Table, and then it won't create a table of the same name on the next sheet. Then, later in the code, I need to make adjustments to the table that was just created before looping to the next sheet.

Is there a way to create a table without giving it a constant name? Or by giving it a name that builds off of other info in the sheet? For example, I would be good with the naming the table after the sheet name: "Sheet1_Table" or such.

Code:
Sub Auto_Open()
'
Dim sht As Worksheet
If Range("A1") = 1 Then

[Code].....

View 2 Replies View Related

Reference Newly Added Sheet

Sep 23, 2007

I have a userform which creates a new sheet using TextBox2.value as the sheet name. Here is the code I am using and it works fine. Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = TextBox2.Value

Here is the problem - After additional code is run on the newly created sheet I need to take the value (Which will be text) from cell AM6 of the newly created sheet and place it on an activecell on Sheet3. Seems simple enough but I do not know how to address this new sheet as I do not know what the name will be. Here is the code I have tried (and various renditions of it)

ActiveCell.FormulaR1C1 = "=TextBox2.Text!R[-9]C[32]"

I do not want to specifically name the new sheet as many sheets could be created, unless you could tell me a way to do that.

View 5 Replies View Related

How Do I Get Past A Delete, Cancel Button During A Macro Loop?

Aug 12, 2009

I would choose to select the delete button. I've created a new worksheet within a workbook, insert text and formatting, and copied to a specific place in the active worksheet. Everything works well except 1. there is a LOT of coding because I recorded the macro and 2. the delete message pops up for every files the macro manipulates. I have to click "delete" about 60 times throughout this macro and would love to be able to let it click its own delete button!

View 6 Replies View Related

Copy Entire Row Into Newly Create Sheet Error?

Apr 2, 2014

This macro below is meant to search a sheet for a user selected value, select the entire row and copy it into a new sheet that has been created under the name of the user selected value. It will create said sheet, but isnt finding the value and/or copying the active cell row. Im not getting any errors so it has no issue with the coding itself, it just doesnt work, have i missed something obvious again?

[Code].....

View 2 Replies View Related

VBA - Create Sheet From Template But Cancel If Sheet Already Exists

Nov 26, 2013

Code:

On Error GoTo ErrorHandler
Dim createsheet As Integer
createsheet = MsgBox("Do you want to Create a Sheet for Uncontrolled Discharge?" & vbNewLine & "NOTE: if the sheet already exists, you cannot create a sheet with the same date - select NO", vbYesNo, "Caution")

[Code] ...

ErrorHandler:
MsgBox "There is already a Sheet Created for that Date.", vbCritical
End If

Right now...it will pop up the error message but it will still create a "template" sheet with the suffix (2), (3), etc... instead of canceling the create new worksheet operation.

View 9 Replies View Related

Excel 2007 :: Cannot Delete Column By Right Clicking

Dec 3, 2013

In any open (new or existing) workbook (Excel 2007), I cannot delete a column by right clicking the column header and highlighting the entire column. The "delete" word is greyed out and not selectable. I CAN however still delete a column by going to the "Cells" toolbar, then "Delete" pulldown menu, then "Delete Sheet Columns". Right clicking the column header is much simpler and easier.

BTW, I can still delete rows by both methods of right clicking on the row header and by going to the Cells toolbar.

View 5 Replies View Related

Simulate Pressing Ctrl+Alt+Delete And Then Clicking Lock Computer

Jul 25, 2007

Is it possible to lock the computer using VBA. i.e Simulate pressing Ctrl+Alt+Delete and then clicking Lock Computer so once this has been clicked the user will have to enter the password to unlock. I thought that using the SendKeys would be a start but this does nothing.

SendKeys "^%{DELETE}"
DoEvents

View 8 Replies View Related

Select Sheet In Userform Cancel Button

Oct 12, 2006

Why is the below code not valid? I am using a userform with a cancel button and i cant it to copy and paste some lines on sheet Chart_Data as it unloads. But i just get the error

"Runtime Error '1004': Method 'Select' of object '_Worksheet' Failed"

Private Sub Cancel_Click()

Chart_Data.Select
Chart_Data.Rows("6:7").Copy
Chart_Data. Range("A4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Unload Me 'Cancels Operation
Exit Sub

End Sub

View 3 Replies View Related

Refresh Particular Sheet On Clicking A Button

Sep 2, 2012

I want to make it possible to refresh a particular sheet on clicking a button. i can create the button and even assign the macro. but the code for macro, to refresh i don't know how to generate the code.

View 6 Replies View Related

Inputbox Button Control + Msgbox For Empty Inputbox

Jun 30, 2009

I have the inputbox so i can set a string value,
When the inputbox Cancle button is pressed i want to exit sub,
If the inputbox value is nothink and ok button, I want the msgbox displayed then goto newname.
If the inputbox has a value do >>>>>>That>>>>>

View 6 Replies View Related

Open Hidden Sheet With Clicking Button?

Aug 23, 2013

I have a workbook including several sheets.

I'd like to hide all worksheets and in the excel there is only one visible sheet which is Navigation Page. I want to add several buttons on this sheet and each button will be clicked to call the other sheets.

For example, there is a sheet called Sales_Approval_Form and I'd like to add a button on navigation page called Sales Approval Form and when the user clicks the button the sheet will be open for entering data.

View 12 Replies View Related

Display The Chart Sheet By Clicking Buton

Mar 18, 2009

I have designed a software in excel/vba and when I run that project then startup form appears which has various buttons on it and they perform different functions.

My problem is when I click on button "View MI Report" at first out of various buttons then it works fine and displays me the excel chart sheet. But If click on any other button first and then on view MI report button then startup form disappears and a file is created at the desktop and then after few seconds startup form again appears but it doesn't display the excel chart sheet. I have written the following code on the button

Private Sub CommandButton5_Click()
For Each wssheet In Worksheets
If Not wssheet.Name = "chart1" Then
wssheet.Visible = xlSheetVeryHidden
End If
Next wssheet

UserForm4.Hide
Sheets("chart1").Select
end sub

View 2 Replies View Related

Prevent To Take Me To Another Sheet When Clicking On A Locked Cell.

Jul 11, 2009

I have one issue with my protected worksheet. Some locked cell contents are linked to cell contents located in another sheet. When I double clicked on these cells, a warning window poped up but also opened the sheet in which the corresponding cell is located. This is quite annoying to have to go back to the former sheet. How can I prevent it ?

View 3 Replies View Related

Select Sheet Using Inputbox?

Jun 5, 2014

i have a close workbook with path ("Z:42766Jan 2 Dec 2014Tally.ERP9GrpSum.xls") from another open workbook i want to popup a inputbox to select the sheet and run the macro on selected sheet.

e.g
i put 2 in inputbox than run the macro on sheet2

View 2 Replies View Related

Referencing A Sheet From An Inputbox

Oct 14, 2008

I have a quick question that'll hopefully have a quick answer. Part of my workbook requires an input box to appear. When you type the name of one of the worksheets into the box and hit enter I want a VLOOKUP formula I've written to compare to that worksheet. Heres what I mean, with some descriptions of what i would like:

View 8 Replies View Related

How To Copy Data To Other Sheet Upon Clicking A Push Button

Jul 13, 2007

I have master data in sheet1 with 4 headings (EmpNo.; Name; Grade; Status) and i put a push button beside it. what i want to happen is that, if i push the button, all data with a value of "Inactive" in sheet1 will be COPIED to sheet2 with the heading but only the EmpNo and Name will be transfered to sheet2.

View 9 Replies View Related







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