View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave O[_2_] Dave O[_2_] is offline
external usenet poster
 
Posts: 19
Default VB Code Is Not Working

Hi, Rob-
I made some changes to your code- with all due respect to your effort
I saw a couple problems in your original version. For instance,
Today() is not a VBA function by itself; I changed that to Int(Now())
which does what you needed it to do. Some other things: you have a
WEND with no WHILE, and your FOR EACH and IF structures overlap: the
IF needs to be self-contained within the FOR EACH, but your IF's END
IF occurs after the NEXT statement.

These points should have become clear when you attempted to compile or
run your code. If I may offer a tip, when you declare variables
include a capital letter in each, and when you enter VBA code type it
in all lower letters. That way when the compiler recognizes a reserved
word or one of your variables, you'll see a letter change case to
upper, and you can then be sure you typed it properly.

Please note some text wrapping may occur in this usenet post: if you
get a compile error you may need to fix a line that was wrapped in
posting.

Hope you'll accept this as the constructive message it was intended to
be~
Dave O

Private Sub Workbook_Open()
Dim rCell As Range

Sheets("Slabber Reports").Select
Range("n8:n5000").Select

For Each rCell In Selection.Cells
If rCell.Value = Int(Now()) Then
MsgBox "Line Item " & rCell.Address & " is now active. Please
perform the appropiate actions to reflect this activity.", vbOKOnly
End If
Next rCell

MsgBox "That's all for today.", vbOKOnly

End Sub