Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

How do I turn a VBA script on and off with an entry in a cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ffzeus - 16 Feb 2006 23:05 GMT
Hi,

I am am trying to cause the below script to populate the date and time
fields when F8 is set to Y and not when it is set to N and to turn on and off
as that field changes without having to restart Excel each time. Any help
would be greatly appreciated.

Thank you.
Script

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Column <> 6 Then Exit Sub
Set rng = Range("F10:F999")
   '   Only look at that range
If Intersect(Target, rng) Is Nothing Then Exit Sub
Application.EnableEvents = False
With Target(8, 6)
If Target.Value = N Then Exit Sub
End With
With Target(1, -3)
.Value = Int(Now() + _
(Worksheets("15 minute").Range("F6").Value - _
Worksheets("15 minute").Range("F7").Value) / 24)
.NumberFormat = "mmm dd, yyyy"
End With
With Target(1, -2)
.Value = Now() + _
(Worksheets("15 minute").Range("F6").Value - _
Worksheets("15 minute").Range("F7").Value) / 24 - _
Int(Now() + (Worksheets("15 minute").Range("F6").Value - _
Worksheets("15 minute").Range("F7").Value) / 24)
.NumberFormat = "hh:mm:ss"
End With
Application.EnableEvents = True
End Sub
Dweeber@HotPOP.com - 17 Feb 2006 00:42 GMT
On the worksheet's module add code for the OnChange event. GEt the
address of the active cell. If the active cell is F8 then, read the
contents and adjust your other cells accordingly. (ie. if the value is
"Y" - fil/updatel the other cells,if  "N" turn off the updating
script.

Hope this helps.

>Hi,
>
[quoted text clipped - 32 lines]
>Application.EnableEvents = True
>End Sub
ffzeus - 17 Feb 2006 00:52 GMT
Hi, Thank you for the reply. I am very new at the whole scripting thing and
have no idea what the code would be. Any samples would be greatly appreciated.

Thank you.

> On the worksheet's module add code for the OnChange event. GEt the
> address of the active cell. If the active cell is F8 then, read the
[quoted text clipped - 40 lines]
> >Application.EnableEvents = True
> >End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.