How To Prevent User Error

Jan 6, 2009

I have a simple spreadsheet which requires a date (mm/dd/yy) in Column A. Columns B-F use formulas to break this date down into the month, quarter, year, etc. Users frequently need to add new rows at the top of the sheet just below the column headers.

To be sure the formulas in Columns B-F are included when adding new rows, I put together a simple macro which copies the top ten rows, inserts them at the top of the sheet, and then clears existing data from the new rows (keeping formulas intact).

I put a button on the sheet to run this macro. However, sometimes users insert new rows without using the macro. This results in no data in Columns B-F for these new rows because the formulas weren’t copied.

How can I prevent this from happening? If I protect the sheet and prevent users from inserting new rows, the macro won’t run. Is there something I can add to the macro that will allow it to run properly while the sheet is protected? Below is the macro code.

Private Sub CommandButton1_Click()
Rows("3:12").Select
Selection.Copy
Rows("3:3").Select
Selection.Insert Shift:=xlDown
Range("A3:A12").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("G3:K12").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A12").Select
End Sub

View 9 Replies


ADVERTISEMENT

Check User Input To Prevent Run-Time Error

Dec 28, 2007

what I want. It relies on an input box asking the user to enter a part code, which when found creates a duplicate copy. However, if the user enters a part that doesn't exist I get a run-time error. Can anybody point me in the right direction so when a user enters an incorrect part they get a message telling them it doesn't exist.

Private Sub SortTest_Click()
Dim s As String
Dim r As Excel. Range

Range("A2").Activate
s = InputBox("Enter the number you wish to find")
If StrPtr(s) = 0 Then
MsgBox "You must enter an existing part number!"
Else
Set r = Cells.Find(What:=s, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

Range(Cells(r.Row, "A"), Cells(r.Row, "AH")).Copy
Sheets("APL").Cells(r.Row, "A").Insert Shift:=xlDown


Application.CutCopyMode = False
Application.Goto Sheets("APL").Cells(r.Row, "H")
Selection.Offset(-1, -5).ClearContents
Selection.Offset(-1, 0).Select
End If

End Sub

View 7 Replies View Related

Prevent The User From Saving The Data Input From The User Form If Any Of Those Three Fields Is Left Blank

Feb 9, 2010

I have a user form that has a combo box "City" two text boxes one called "Flight" and the other "Date". What I'm trying to do is to prevent the user from saving the data input from the user form if any of those three fields is left blank. The code that I have so far checks all of the required fields, if any are left blank a message notifys which field(s) is left blank and return the focus back to that field. But the rest of code also fires.

What I really need is either to stop the code if any fields are blank and return the focus back to the blank field, the user completes the field(s) and clicks the save again, or better yet, pause the code until all the required fields are completed and then complete the save. (There is actually another 200+ lines of code in this sub, but I deleted it to keep the post a little shorter.)

View 2 Replies View Related

Prevent User From Accessing The Excel File When It Is In Use By Another User

Jul 22, 2013

An Excel file named CLEARING is availble in thr central server system. it will be accessed by 5 or 6 staffs from some other systems what i need is when one person accesses/edits this file the others should not even able to open in the read only file ,when the file is saved and closed ,then only the next person should access it

View 1 Replies View Related

Prevent User From Typing On Worksheet?

Feb 11, 2009

I have tables on a spreadsheet and userforms created. Is there anyway to prevent users from just typing on the worksheet so they will have to use the userform?

View 4 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

Prevent The User From Scrolling In A Sheet?

May 14, 2007

I have an Excel sheet that displays 50 rows and 20 columns when it is opened the first time. These rows and columns are the only ones that I want the user to be able to see. The user shouldn't be able to navigate the sheet by using the scroll bars or the wheel on the mouse. I have of course already removed the scroll bars but I don't know how to handle the scroll wheel problem.

View 2 Replies View Related

Prevent Formula Being Deleted When Visible To User?

Apr 20, 2013

I am using following code to effect a change which works fine:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheets("Closed Flts").Unprotect "abcd"
Sheets("Faults").Unprotect "abcd"

[Code].....

But when the sheet is unprotected to effect this change the formula in cells ( row I and L) are visible to user and can delete them. Or they can even delete the cell itself or modify formula.

The formule in Row I is
Code:
=IF(A12="","",IF(G12=1,A12,IF(G12=2,A12,IF(G12=3,A12+1,IF(G12=4,A12+5,IF(G12=5,A12+28,"priority?"))))))
And in Row L is
Code:
=IF(A13="","",IF(I13

View 1 Replies View Related

VBA Code Prevent A User From Changing Cell Contents

May 26, 2009

Is it possible to write VBA code that will prevent a user from changing a cell's contents, depending on the cell's font color?

More specifically, I have a column of text in range B15:B64. Some of the cells will have a black font, others will be blue. Is it possible to lock the black font cells only, leaving the blue cells unlocked for users to change?

View 9 Replies View Related

How To Prevent User From Clicking On Days In Calendar Control 8.0

Jun 22, 2013

Is there a way to prevent a user from clicking on the days in the Calendar Control 8.0? I am trying to place 12 calendar controls on a worksheet for reference only. I am using a linked cell to reflect what date the Calendar is to display.

View 2 Replies View Related

Prevent User To Enter Duplicate Using Data Validation?

Dec 27, 2013

I want to prevent user from entering duplicate text or numbers in a cell using the Data Validation.

View 9 Replies View Related

Prevent User Seeing Senstive Information In Hidden Rows/Columns

Aug 19, 2008

I have a feeling the answer to this will be 'no' based on the searching I've done, but is it possible to allow formatting of rows/columns on a protected worksheet, yet prevent the user from unhiding some rows/columns I don't want them to see? I've allowed them to format rows/columns so they can "size" them to fit the text they enter, but that has opened up the ability for them to unhide columns. Using Shrink To Fit would be cumbersome due to the number of cells involved.

View 5 Replies View Related

Prevent Do While Loop From Doing Go To Error

Apr 4, 2014

I've got the following code which opens/gets the excel files from a specified directory and imports them into an open workbook. I've added a GoTo Error before my loop which checks if there are any files in the directory and shows an error message if it's the case. Problem is since the loop goes on till there are no more files in the directory, it goes back to the error. How to change that ?

View 3 Replies View Related

Hide/Prevent #DIV/0 Error

Apr 6, 2008

My wife is trying to use an Excel Spreadsheet to help teaching fractions and decimals to children.

She wants a cell where the children enter the numerator and a cell where they enter the denominator and a cell where the result (to two decimal places) is shown. I have designed an appropriate sheet but would like to "fancy it up" a little.

If the denominator cell is empty, the result cell shows the error message "#DIV/0!".

I'd like this message to be hidden until the children have entered both a numerator and a denominator.

The numerator is in cell D2, denominator is in cell D6 and result is displayed in merged cells C8 - E8.

I've tried conditional formatting the cell with white text if the cell is zero and black if it is non-zero and also tried to specify white text if the cell value is equal to "#DIV/0!" but both do not do what I want.

If there was a way to specify white text for this cell if another cell was zero, that would do it too (ie. if cell D6=0 then conditionally format cells C8-E8 to be white text).

I've also tried a rather inelegant solution where the denominator cell has a "dummy value" (say 0.1) and then conditionally formatted this cell to make the text white (so that it doesn't show up). The results cell can then be conditionally formatted with two conditions: 1. If cell = 0 then white text and 2. if cell is non-zero black text. However, this means that as soon as any number is entered into the numerator, the results cell becomes visible.

Example. Initially cell D2 is blank, D6 has "dummy" value 0.1 and results cell (C8 - E8) has the value 0 in it (0 / 0.1 =0) conditionally formatted to be "invisible".

When a positive number is entered into cell D2 (the numerator) such as 2, the result (2 / 0.1 = 20) is non-zero and so 20.00 is displayed.

How can I hide the error message "#DIV/0!" until the denominator is no longer zero?

View 6 Replies View Related

INDEX/MATCH: How To Prevent #N/A Error

Apr 6, 2009

I have a situation in which I want to SUM several costs in separate columns according to the date to which they correspond.

(see attached sheet with dummy example)

eg: any cost falling on April 3, sum them and give the total amount.

I can achieve this using iterations of the following formula:

View 3 Replies View Related

Prevent/Stop #DIV/0! Error In Formula

Apr 21, 2009

The attached file contains hypothetical data on a basketball player's success from the free throw line. It lists the number of free throws attempted and the number made and then divides the number made by the number attempted to calculate the free throw percentage. However, I keep getting a # DIV/0! error in the games free throws weren't taken. How do I write the code so that when the error occurs, a message is displayed to the effect that no percentage can be reported because no free throws were attempted by checking the cell in column D? How do I use the IsError function to figure this out?

View 2 Replies View Related

Prevent #REF! Error When Deleting Rows

Mar 18, 2008

I have a form on a SheetA wherein all cells are referencing the data in cells on SheetB. When I delete or add a row on SheetB, the cells in that row on SheetA read REF#. I need the row in SheetA to be added when I add it in SheetB and vice versa for when I delete a row.

View 5 Replies View Related

Prevent Formula Showing Error Values #DIV/0!

Jan 18, 2008

I Spoke too soon here, I am getting value errors, how to do it with conditional formating. I tried if cell value is =to #DIV/0! then white (dosent work). Richard this dosent seem to work mate =IF(SUM(F6:V6),"",AL6/SUM(F6:V6))

View 9 Replies View Related

Prevent Loss Of Data - Error Message Pops Up

Sep 11, 2013

What is this error message that is popping up when I try to insert a blank row of cells?

"To prevent possible loss of data, Excel cannot shift nonblank cells off of the worksheet. Select another location in which to insert new cells, or delete data from the end of your worksheet.

If you do not have data in cells that can be shifted off the worksheet, you can reset which cells Excel considers nonblank. To do this, press CTRL + End to locate the last nonblank cell on the worksheet. Delete this cell and all cells between it and the last row and column of your data then save."

This excel document we have has LARGE amounts of data

View 3 Replies View Related

Remove References Programmatically & How To Prevent Debug Error

Jun 19, 2009

i m working on an excel 2007 workbook with ms project functionality. in order to be able to use ms project from within excel i m using early binding. for those who dont know what early binding is: http://www.dicks-clicks.com/excel/olBinding.htm

this works fine if the user has ms project installed on his/her pc.

if the user does not have ms project installed i remove the broken references. this works fine.

but my problem is that when i remove the reference to ms project, my vba project will not compile correctly. thus each time when a user opens the workbook the user gets a "compile error in hidden module" , since the functions of ms project are not available.

for example i get a compile error in the following source
Public Function getResID(ResName As String, ActiveProject As Project) As Integer
Dim res As Resource
For Each res In ActiveProject.Resources
If res.name = ResName Then
getResID = res.ID
Exit Function
End If
getResID = -1
Next
End Function
i just want to know what i can do to prevent the compile error? would the use of late binding remove the problem? actually i dont want to use late binding since my source code is already very complex and it would be a huge effort to change it.

View 9 Replies View Related

Stop/Prevent #VALUE In Formula Reference Error Cell

Sep 3, 2006

A1 refers to B1 which contains a number or #VALUE!

What could I use in A1 to return a number and if B1 = #VALUE!, a zero.

View 9 Replies View Related

Prevent #DIV/0 Error In Average When All Cells Are Blank/Empty

May 19, 2008

I'm looking for a function that will display the average of a row of cells, while at the same time not displaying any error messages. It's easy to average cells without blank values, but to combine that with no errors is difficult for me. I saw many ways to do the average, one of which is:

= SUM(A1:E1)/COUNTIF(A1:E1,">0")

That function doesn't work for a row of blank cells (i.e., hidden rows), though. The result is an error message.

I also read about a way to ignore an error in a computation:

=IF(ISERROR(F1),"",F1)

The problem is when I combine those functions I get a blank cell no matter which function I put first, and without regards to cell values or not. The reason I want this to be error-free is that I have to average the "average column" at the bottom of the table, too (i.e., F100).

View 9 Replies View Related

PRINT Macro: Prevent Error When Canceling At InputBox Level

Apr 18, 2009

I have a macro that asks the user what pages they would like to print on a particular sheet. In the example below, a button will be assigned to pages 1-5 on a sheet and thus the user has the option of printing from page 1 up to page 5. Any page number outside this range will result in an error message and the user will be asked to re-enter the end page number. This is the code I pulled from this forum and partially modified:

View 4 Replies View Related

Prevent Linked Cells Showing Error When Deleting Rows On Other Sheet

Feb 14, 2013

I want to establish a link from my worksheets. Using the conventional link method I was able to link the values from my first worksheet to the second worksheet. My problem is when I delete a particular row. The reference of the second worksheet will have an error #REF! since I deleted those cells. Is there any way that I can link my two worksheets without any error that even if I deleted a particular cell/row the reference is still intact?

View 2 Replies View Related

User Log Error Message

Jun 10, 2006

I've got the below code which I use to log users who opens my spreadsheet. It's a Event so runs when the spreadsheet is open with macro enabled. The spreadsheet is on a shared drive which has the prefix "K". Most users it works find but one user gets a error Message "Path or Drive" error. I got around it by adding "on error" but how do you overcome issues with drive prefixs and the drive address e.g "K" vs "\CRD2000"

Private Sub Workbook_Open()
Open ThisWorkbook.Path & "usage.log" For Append As #1
Print #1, Application.UserName, Now
Close #1
End Sub

View 4 Replies View Related

Out Of Memory Error Using A User Form

Jan 22, 2007

I have a userform with about 20 multipage tabs, each of which has quite a few text and combo boxes. My problem is I think I have reached some physical limits for the number of controls on the userform. When I try and add code for the userform I get an "out of memory" error.

I thought I have seen some limits on the length of macro code before, but couldn't find them again. If anyone could let me know the limits on userform controls and the number of VBA lines allowed behind the userform, that would be great.

I have tried to put as much of the code as possible in public subs, but there is still a fair amount of code that is associated with things like the AfterUpdate function and I don't know of any other place to put this code. Please let me know if there is another way to put this code in so I don't run out of room.

View 3 Replies View Related

Excel 2003 :: Runtime Error For One Particular User

Jun 10, 2014

I have a workbook in Excel that runs some code when it is opened [see below].

It works fine for everybody except one person using Excel 2003 - they get a Run-time error '5' : invalid procedure call or argument message and I cannot figure out why.

[Code] ......

View 2 Replies View Related

InputBox Error :: Get A Range A Data From The User

Aug 1, 2008

I am using an inputbox to get a range a data from the user.

View 10 Replies View Related

Returning Error From User Defined Function

Feb 7, 2007

A client has a registration workbook for each student which contains 3 types of worksheets, A) Transcript B) Registration and C) Grade sheets. Each file has only 1 Transcript sheet and 1 to many pairs of Registration and Grade sheets.

I have a GPA user defined function which obviously can only be used on a Grade sheet. I would like to return an Error if the user trys to use the udf on a non Grade sheet.

Currently I am just returning 1/0 but the smart tag returns #Name. Can I control the text displayed somehow?

View 9 Replies View Related

User-Defined Funct. Object Error

Jun 19, 2006

I am trying to format user entered data. They insist upon placing text where only number should be. I found this function in O'Reilly's Excel Hacks, and it works if I place it in a cell (e.g. "=ExtractNum(K37)"), but I am stuggling with a error message when I try to place it in my code (see the code after the function). I have hundreds of protential cells over dozens of worksheets in my workbook, and I would rather not have to do it cell by cell.

I get the error message of:

Runtime error '424', Object required

I have tried serveral different combinations on my
"ValDec = ExtractNum(MyRange)". I know I am probably missing something, but I can't seem to find what.

Function ExtractNum(ByVal rCell As Range)
Dim lCount As Long, l As Long
Dim sText As String, lNum As String

sText = rCell

For lCount = Len(sText) To 1 Step -1
If IsNumeric(Mid(sText, lCount, 1)) Then
l = l + 1
lNum = Mid(sText, lCount, 1) & lNum
End If

View 6 Replies View Related







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