[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Clearing cell contents

rbbbbeee

12/15/2006 4:19:00 AM

I have a macro that when a name is entered in cell A1 a pop up window appears
asking for the birthday of the person who's name was entered. The birthday
date is then entered into cell A39. The macro works great this far. The
problem is that when the name of the person in cell A1 is deleted, I need to
have the birthday date also deleted in cell A39. What is the best way to do
this? Please help me soon!
See the coding below:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False
If Target.Address = "$A$1" And Target.Value <> "" Then
B_Day = InputBox("enter your birthday")
Range("A39").Value = B_Day
End If
stoppit:
Application.EnableEvents = True
End Sub

THANKS in advance!
Russ
2 Answers

Dave Peterson

12/15/2006 4:27:00 AM

0

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim B_Day As String
On Error GoTo stoppit
Application.EnableEvents = False
If Target.Address = "$A$1" Then
If Target.Value = "" Then
Me.Range("A39").Value = ""
Else
B_Day = InputBox("enter your birthday")
Me.Range("A39").Value = B_Day
End If
End If
stoppit:
Application.EnableEvents = True
End Sub


rbbbbeee wrote:
>
> I have a macro that when a name is entered in cell A1 a pop up window appears
> asking for the birthday of the person who's name was entered. The birthday
> date is then entered into cell A39. The macro works great this far. The
> problem is that when the name of the person in cell A1 is deleted, I need to
> have the birthday date also deleted in cell A39. What is the best way to do
> this? Please help me soon!
> See the coding below:
>
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> On Error GoTo stoppit
> Application.EnableEvents = False
> If Target.Address = "$A$1" And Target.Value <> "" Then
> B_Day = InputBox("enter your birthday")
> Range("A39").Value = B_Day
> End If
> stoppit:
> Application.EnableEvents = True
> End Sub
>
> THANKS in advance!
> Russ

--

Dave Peterson

rbbbbeee

12/15/2006 11:34:00 PM

0

Thanks Dave! It works great!

Russ

"Dave Peterson" wrote:

> Option Explicit
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> Dim B_Day As String
> On Error GoTo stoppit
> Application.EnableEvents = False
> If Target.Address = "$A$1" Then
> If Target.Value = "" Then
> Me.Range("A39").Value = ""
> Else
> B_Day = InputBox("enter your birthday")
> Me.Range("A39").Value = B_Day
> End If
> End If
> stoppit:
> Application.EnableEvents = True
> End Sub
>
>
> rbbbbeee wrote:
> >
> > I have a macro that when a name is entered in cell A1 a pop up window appears
> > asking for the birthday of the person who's name was entered. The birthday
> > date is then entered into cell A39. The macro works great this far. The
> > problem is that when the name of the person in cell A1 is deleted, I need to
> > have the birthday date also deleted in cell A39. What is the best way to do
> > this? Please help me soon!
> > See the coding below:
> >
> > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> > On Error GoTo stoppit
> > Application.EnableEvents = False
> > If Target.Address = "$A$1" And Target.Value <> "" Then
> > B_Day = InputBox("enter your birthday")
> > Range("A39").Value = B_Day
> > End If
> > stoppit:
> > Application.EnableEvents = True
> > End Sub
> >
> > THANKS in advance!
> > Russ
>
> --
>
> Dave Peterson
>