Workbook Code Errors When Orginal Sheet Hidden Or Deleted
Oct 14, 2007
I copied the sheet and redid the format. I renamed the original dashboard sheet from count to "keep" and named the copy after the original "count" Everything still works great - until i either hide or delete the original count which is now named "keep". I get an error at the red colored line below ".publish false".
I have attached an image of the error....
View 7 Replies
ADVERTISEMENT
Mar 25, 2008
I have added this bit of code to change the apperance of entered time from 0835 to 08:35
UserInput = Target.Value
If UserInput > 1 Then
NewInput = Left(UserInput, Len(UserInput) - 2) & ":" & Right(UserInput, 2)
Application.EnableEvents = False
Target = NewInput
Application.EnableEvents = True
End If
And it works like a charm. Except that if the content in one of the cells later is deleted a "Run time error 13" is the result. Debug leeds to the line "If Userinput >1 Then"
Can this error be avoided..?
View 3 Replies
View Related
Apr 15, 2008
I used the code below for Conditional Formatting. This works fine but the VBA-code crashes when I delete more than one selected cell. Is there a simple modification possible to prevent this from happening?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A1:C250")) Is Nothing Then
Select Case Target
Case 1
icolor = 6
Case 2
icolor = 12
Case 3
icolor = 7
Case 4
icolor = 53
Case 5
icolor = 15
Case 6
icolor = 42
Case Else
'Whatever
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub
View 3 Replies
View Related
Oct 20, 2008
I have a workbook with 20+ sheets in it, I add sheets and delete sheets on a daily basis, except for one sheet that is like my summary sheet.
Is there a code, formula, or magic spell that will list the names of the sheets that I have deleted? For instance, if my workbook has 50 sheets and I delete 49 of them, I want to see cells A1 thru A49 (or where ever I wish to place them) filled with the names of the sheets I just deleted.
View 9 Replies
View Related
Mar 4, 2008
I have a macro set up on a command button so that when you click the button, it takes the info that you entered and puts it into line form on a seperate sheet. I need it to clear the original sheet after this happens, but the way I have it set up, when you remove the info from the original sheet it removes it from the second sheet. Does any one have a sample form that submits information this way? I think I can figure it out if I could see how someone else has done it.
The form is set up so that the user has to enter their name and then go through a series of drop down boxes, and select the correct options and then submit the form when done.
View 3 Replies
View Related
Dec 12, 2013
I have a userform which clones the latest sheet and produces copy of it on the next sheet. The first sheet they will be cloning is the sheet called 'template', I however want this to be hidden since I do not want anybody to modify a sheet which basically serves purpose of a template. And once cloned, it is no longer needed.
On the click of the command button, the macro will create sheet1 taking the info from sheet named 'Template' in the same workbook . And now on the next click of the command button, Sheet 2 is created taking the info from sheet1 and Sheet 3 is created taking the info from Sheet 2 and so on. Here is what I currently have, so how can i modify it in order for my scnerio to work?
To select the last sheet in the workbook
Code:
Sheets(Sheets.Count).Select
To create new sheet
Code:
Sheets(Sheets.Count).Copy After:=Sheets(Sheets.Count)Sheets(Sheets.Count).Name = MyEvent & " " & MySCN & "(" & ThisWorkbook.Sheets.Count - 2 & ")"
View 3 Replies
View Related
Jul 13, 2009
I have placed the code I am using below. It takes values from a hidden sheet (PACTAct) and places them on a visible sheet (Email). The code moves between the two.
It works at the minute by unhiding the PACTAct sheet then at the end re-hiding it. However I don't want the user to see this sheet whilst the vba is running. Is there a way I can simply refer to the worksheet without unhiding it?
View 6 Replies
View Related
Apr 13, 2008
Consider two instances of Excel - one with a workbook containing a chart and some VBA code, the other containing a blank workbook. When I paste a chart from the first instance of Excel to the other, all the VBA code from the original workbook is also pasted into a new third hidden workbook in the second instance of Excel! If that weren't weird enough ON WINDOWS XP (but not Windows 2000) if the VBA code included WorkbookOpen or AutoOpen this code is executed in the second instance of Excel, which of course fails if it references sheets that only existed in the workbook open in the first instance of Excel! This is the first time I've seen the same version of Excel do different things on different versions of Windows! Example attached - What's going on!? Auto Merged Post Until 24 Hrs Passes;...note: this does not happen when pasting charts between workbooks open in the SAME instance of Excel
View 6 Replies
View Related
Aug 25, 2009
I need this code below to work in a macro on a hidden sheet.. FYI the sheet name is "Closed".
View 2 Replies
View Related
Nov 30, 2012
I am currently working with a hidden sheetname "hide_template" which contains formula linking to another sheetname "rawdata" of same workbook.
In this "rawdata", the contents is updated from time to time.
The problem is when I open this workbook and update the entries in "rawdata", the formulas/results in "hide_template" is not updated and invalid (ie. #N/A, #VALUE..)
This is the overview of process that Im working with:
===> open workbook ===> paste new entries on "rawdata" ==> run a macro to copy range in the "hidden_template" to paste to new sheet of same workbook
I already have a working macro to copy range from the "hidden_template" which works as follows:
===> set to visible the "hidden_template" ===> copy range from "hidden_template" ===> paste to new sheet ===> set to hidden the "hidden_template"
View 1 Replies
View Related
Jun 30, 2007
im looking for a basic macro for workbook copying, all workbook(all hidden, unhidden, and very hidden) sheets.
i know how to do unhidden sheets of course however the hidden and very hidden are giving me some trouble...i need to also copy over all the macro's, buttons, and drop down box's as well..not just values.
View 4 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, 2013
I have this code that removes a group of cells on any row that contains "Y" in Column L, but it does not move the remaining group of cells on a row up after the cells are deleted.
VB code so that when a range of cells are deleted, the row(s) below are moved up?
Sub RemoveReceived()
LastRow = Cells(Rows.Count, "H").End(xlUp).Row 'change "H" to the column that determines which is the last row
For x = LastRow To 4 Step -1 'assuming it starts from row 4
If Cells(x, "L") = "Y" Then
Range("H" & x & ":K" & x).ClearContents ' or use Delete
[Code] ........
View 2 Replies
View Related
Feb 3, 2010
I have a workbook that contains several formulas that return #value! errors. My formulas are correct and I can remove the error by using an "if" function, but there are a lot of these cells. I just want to make the error show blank to make my workbook look nicer without having to write formulas to avoid the error messages. Is there something I can add in the VBA worksheet function to turn off these errors?
View 2 Replies
View Related
Sep 5, 2007
I have an existing code that runs almost flawlessly but I am running in to formatting cells error (or at least I think that is the problem).
For example, here is a line of code where my error lies:
If Worksheets(FirstSheet).Cells(Counter, ColtoMove) = MoveIf Then
'DO SOME ACTION
If I put my cursor on MoveIf it shows the expect number of 4500016239…….BUT it errors!
When I step through the code and go to the worksheet (or go to the left side of the = in the above code the data in the cell is “4.5E+09“.
I’ve attempted to change the formatting of this cell range to “Text” by the following With statement:
With Worksheets("CreateOrderFormsData")
.Range("AC:AC").NumberFormat = "Text"
End With
Note: if I verify the cells formatting after the above code is ran by rt click on the cell, format cells the Number field is set to “CUSTOM” and the Type: field is set to “TEXT”. Is this the problem? Please read on.
But that did not seem to do the trick…..actually if I now go to the left of the = again (which is now set to text) the data is “###########” in the cell, in the formula bar the number is the expected 4500016239 though but the CODE STILL FAILS!
Am I on the right track…..can anyone assist with this error please?
View 9 Replies
View Related
Jan 26, 2008
Sub CombineWBs()
Dim wb As Workbook
Dim newWB As Workbook
Dim i As Long
On Error Resume Next
With Application.FileSearch
.NewSearch
.LookIn = "C:Budget"
.Execute
Set wb = Workbooks.Open(.FoundFiles(1))
RenameWS wb
wb.Worksheets.Copy
Set newWB = ActiveWorkbook
wb.Close SaveChanges:=False
For i = 2 To .FoundFiles.Count
Set wb = Workbooks.Open(.FoundFiles(i))
RenameWS wb
wb.Worksheets.Copy After:=newWB.Worksheets(newWB.Worksheets.Count)
View 9 Replies
View Related
Oct 15, 2008
My code works well if the worksheet name is Sheet1. It will change constantly. I have alot of other similar workbooks that are not affected and cannot figure this out. Here is the code that I get the error at: ....
View 9 Replies
View Related
Nov 21, 2006
I have a workbook which includes a simple set of options on closing such as selecting the front sheet, restoring scrollbars and saving the workbook. To avoid problems with subscripts out of range I am using the ThisWorkbook statement to close the workbook.
This works fine and causes the workbook to close when close is clicked on any excel window. The problem is that excel falls over when it tries to resume closing the other workbooks. I am given (ironically) an error saying "excel has encountered a problem and needs to close". Does anyone know how to work around this?
My code is below:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call Toolbars9(True)
With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayWorkbookTabs = True
End With
View 8 Replies
View Related
Mar 6, 2008
i would like an if macro to pick up if cell dest (i have used a case to define this cell) contains an error or more imoprtantly #REF! then change the offending cells to 0 and put up a message box to put "Check XTA". i have found some that i think may work but i didnt understand them (they had function in them :smask so i couldnt put them in.is there a way to put them in with out functions or could someone point me in the right direction.
View 4 Replies
View Related
May 9, 2008
how to supress the continue,end,debug, message when there is a vba error. The idea being that if there is a bug in my system that I have no realised, I don't want my end user seeing that message! I would preferrable design my own error message to appear instead.
View 2 Replies
View Related
Sep 18, 2007
I have a sheet (sheet2) that has cells in column L, M and N referencing cells in another sheet (sheet1)(same workbook).
If I delete a row out of Sheet1 it causes the formula in Sheet2 to go to #REF.
Normally the formula would be something like
='Sheet1'!L13
How can I get these formulas to not change just because cells where deleted from Sheet1?
View 9 Replies
View Related
Nov 30, 2009
I have a rather large workbook (30 sheets, 10MB) that has one worksheet with many INDIRECT functions in it (pulling data from the same file, different tabs). I am working to put simple code into the workbook to protect and/or unprotect all worksheets. I have gotten code to work to both protect and unprotect all the sheets, but when I run the unprotect code (see below), and then I go to edit the workbook, data from the sheet with many "indirect" functions temporarily "overwrites" the data on the active sheet (this is fixed when I scroll my mouse over the effected cells). I am developing this workbook for other users, so I'd like to fix this before sending it off to them.
This problem does not happen until after I run the following .....
View 14 Replies
View Related
Jul 15, 2014
the following two statements return the error "Application-defined or object-defined error"
Code:
Sheets("Purchase").Range("PurchaseTax").FormulaR1C1 = "=IF(RC[-1]0,ROUND(RC[-1]/11,2),"")"
Sheets("Purchase").Range("FreightTax").Formula = "=IF(FreightCharge0,ROUND(FreightCharge/11,2),"")"
View 2 Replies
View Related
Aug 12, 2009
I am currently creating a database which involves using a macro to create new worksheets in the workbook. When the macro is run and a work sheet is being inserted, an input box asks the user for a worksheet name.
As you can imagine, the worksheet does not like it when the worksheet name input by the user, is the same as one already existing and so throws up a 1004 error.
In order to resolve this error I have included an error handling code to request the user to input a differnet worksheet name, as the one previously inserted exists.
My problem: It all works fine until the user types in an existing worksheet name twice, so once initially and again when the error handler has prompted a second attempt. On the second incorrect input a 1004 error warning is displayed.
I would like the error handler to keep repeating until a worksheet name that doesn't exist is inserted by the user. Is this possible?
My code so far:
Sub NewTrancheSheet()
'
Sheets("Tranche Sheet Template").Visible = True
Sheets("Tranche Sheet Template").Select
Sheets("Tranche Sheet Template").Copy Before:=Sheets(1)
Sheets("Tranche Sheet Template (2)").Select
Sheets("Tranche Sheet Template (2)").Move After:=Sheets(Sheets.Count)
Sheets("Tranche Sheet Template (2)").Select.................
View 9 Replies
View Related
Jul 23, 2014
On occasion I cut a table from a website and paste into Excel. If/when that data is subsequently deleted from the sheet the gridlines no longer show. I've tried turning the gridlines on and off to know affect. I've tried setting and clearing borders, but that made no different to the gridlines either. Even if I highlight the entire sheet and delete it makes no difference. I can't think of anything else to try.
View 2 Replies
View Related
Jun 27, 2008
why this code does not work when the worksheet is changed between range "B1:F5"?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B1:F5")) Is Nothing Then
With Range("B1:F5")
Cells(Target.Row, 7) = Cells(Target.Row, 6).Value + Cells(Target.Row, 5).Value
End With
End If
End Sub
View 3 Replies
View Related
Nov 5, 2013
Ok, I have a spreadsheet that I use to track the majority of my work throughout the day. I have about 10 columns that I use for my own information, and about 4 of them that my colleagues need updates on. I have one sheet "worktracking" and another sheet "printable." Printable has just the 4 columns of info that my colleagues might need, formatted in a way that prints out nicely. Each column in "printable" references a column in "work tracking" like this
='worktracking'!c2
Now the problem that I'm running into is that I routinely delete rows from the "worktracking" sheet, which results in a reference error on the "printable" sheet. I am wondering if there is a way to rework it, such that when I delete a row from "worktracking," then "printable" just does the same, and only retains rows that have data in them...
View 3 Replies
View Related
Jan 11, 2013
I am looking for the code that I would use so that when the workbook is opened it would always open with "Main" sheet.
View 4 Replies
View Related
Feb 20, 2013
I'm about get code for list out the sheet names in current workbook, list would be displayed in a new sheet at the end.
View 3 Replies
View Related
May 17, 2013
i need a code to hide the sheets tab from the workbook. and only show the horizontal scroll bar and vertical scroll bar.
View 1 Replies
View Related