Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
error handling message help
Hi there,
I have a macro which enables users to import values into a master log. Each row inserted into the master log has a unique date. Question: I'd like to add some code in which Excel loops through the existing rows in the master sheet and checks that the date to be inserted doesn't already exist. if it does exist, display a message which enables the user to overwrite the existing entry or cancel the import process. Ideas? -- Carlee |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
error handling message help
Hi Carlee -
Here's some code to test in your application. It assumes your MasterLog data range begins in A1 and the date is in column(1). Adjust to suit. Sub Carlee() Const d = "5/19/07" Set dataRng = Range("A1").CurrentRegion If Not dataRng.Columns(1).Find(d, LookIn:=xlValues, _ lookat:=xlWhole) Is Nothing Then If MsgBox("Date already exists in MasterLog." & Chr(13) & _ "Press OK to overwrite or CANCEL.", vbOKCancel) = vbOK Then 'Call your code to insert the record, but overwrite instead MsgBox "Overwriting..." Else MsgBox "Canceled; no overwrite..." End If End If End Sub --- Jay "Carlee" wrote: Hi there, I have a macro which enables users to import values into a master log. Each row inserted into the master log has a unique date. Question: I'd like to add some code in which Excel loops through the existing rows in the master sheet and checks that the date to be inserted doesn't already exist. if it does exist, display a message which enables the user to overwrite the existing entry or cancel the import process. Ideas? -- Carlee |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
error message handling #N/A | Excel Discussion (Misc queries) | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
Error handling. | Excel Programming | |||
Error handling with a handling routine | Excel Programming | |||
error handling | Excel Programming |