PC Review


Reply
Thread Tools Rate Thread

How to avoid: Error of run Time '13'

 
 
=?Utf-8?B?ZGlsZXR0YW50ZQ==?=
Guest
Posts: n/a
 
      2nd Oct 2006
Hello,

I use follwing listing to insert two dates ina workbook:

Sub InserimentoPeriodo()
Dim DataInizio As Date
Dim DataFine As Date

If ActiveSheet.Name <> "Rates1" Then
Worksheets("Rates1").Activate
End If

DataInizio = InputBox("Inserisci la data di INIZIO periodo nel formato
gg-mmm-aaaa", "Confronto Variazioni Prezzi", "1-mag-1997")

If Year(DataInizio) <> 1997 Then
MsgBox "Usare solo date dell'anno 1997", vbOKOnly
Exit Sub
End If
Range("E1").Value = DataInizio

DataFine = InputBox("Inserisci la data di FINE periodo nel formato
gg-mmm-aaaa", "Confronto Variazioni Prezzi", "10-set-1997")
If Year(DataFine) <> 1997 Then
MsgBox "Usare solo date dell'anno 1997", vbOKOnly
Exit Sub
End If
Range("E2").Value = DataFine

End Sub

If I answer to the imputbox question with "Cancel" I get the message:
Error of run Time '13'
How may avoid it?

Thank you for helping

--
dilettante
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      2nd Oct 2006
One solution would be to use "On Error GoTo Next" (without the qotemarks)
just before your IF statement. Another would be to include another IF
statement that says
If Data Inizio = "" Then
(do something)
End If"

"dilettante" wrote:

> Hello,
>
> I use follwing listing to insert two dates ina workbook:
>
> Sub InserimentoPeriodo()
> Dim DataInizio As Date
> Dim DataFine As Date
>
> If ActiveSheet.Name <> "Rates1" Then
> Worksheets("Rates1").Activate
> End If
>
> DataInizio = InputBox("Inserisci la data di INIZIO periodo nel formato
> gg-mmm-aaaa", "Confronto Variazioni Prezzi", "1-mag-1997")
>
> If Year(DataInizio) <> 1997 Then
> MsgBox "Usare solo date dell'anno 1997", vbOKOnly
> Exit Sub
> End If
> Range("E1").Value = DataInizio
>
> DataFine = InputBox("Inserisci la data di FINE periodo nel formato
> gg-mmm-aaaa", "Confronto Variazioni Prezzi", "10-set-1997")
> If Year(DataFine) <> 1997 Then
> MsgBox "Usare solo date dell'anno 1997", vbOKOnly
> Exit Sub
> End If
> Range("E2").Value = DataFine
>
> End Sub
>
> If I answer to the imputbox question with "Cancel" I get the message:
> Error of run Time '13'
> How may avoid it?
>
> Thank you for helping
>
> --
> dilettante

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid having to click Allow each time Craig Microsoft Access Macros 2 27th May 2011 04:36 PM
Can i avoid typecasting all the time by overloading an operator Jon Skeet [C# MVP] Microsoft C# .NET 7 21st Mar 2008 03:54 PM
How do I avoid having to give Password, etc. at Restart time =?Utf-8?B?RG9uIEphbWVz?= Windows XP General 6 22nd Nov 2006 01:53 AM
How to avoid multiple OUTLOOK GUIs at the same time ? =?Utf-8?B?dHZ6?= Microsoft Outlook Discussion 4 1st Jun 2006 04:43 PM
Exception firing at design time - how to avoid? Jack Addington Microsoft C# .NET 1 9th Dec 2004 06:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 PM.