Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I have had help putting this code together, but can't get it to work properly. The code checks a worksheet named 'sweep log' Column C for today's date, if its not found then a msg box "todays date not found" is displayed, or if it is found then a check that data is also entered into the adjoining columns D and E. Problem is that the checks are carried out and the correct msg boxes are shown but on acknowledment of these the worlsheet closes, instead of allowing the data to be entered. The code has been placed within the Before Close event, and is shown here... Dim TimeCheck As Date TimeCheck = Format(Now(), "h:mm") If TimeCheck "09:00" Then Dim WS As Worksheet Dim sRng As Range Dim x As Object Dim sDate As Date sDate = DateSerial(Year(Now()), Month(Now()), Day(Now())) Set WS = Sheets("sweep log") With WS Set sRng = Range(Cells(6, 3), Cells(65536, 3).End(xlUp)) Set x = sRng.Find(What:=sDate, LookIn:=xlFormulas, SearchDirection:=xlNext) If x Is Nothing Then MsgBox "Todays Date not found" ' edit as needed SweepCheck = False Exit Sub End If If ActiveCell.Offset(0, 2) < "Y" Then If ActiveCell.Offset(0, 1) = "" Then 'change to Yes if needed MsgBox "verify sweep completed" 'this is old location WS.Activate 'if "Y" is not found in same row as todays date then go to the empty cell below x.Offset(0, 2).Select Exit Sub End If 'this is new location End If End With End If it must be something simple, but being a novice, I can't put my finger on it any help apreciated thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
do anybody have a sample code for executing excel macro from vb code?<eom | Excel Programming | |||
Create a newworksheet with VBA code and put VBA code in the new worksheet module | Excel Programming | |||
stubborn Excel crash when editing code with code, one solution | Excel Programming |