D
DDD
Currently, i am running Excel 2007 at this moment.
This is exactly what i have done
I went to the the appropriate worksheet, went to the "Developer" tab &
clicked on "Visual Basic", in the blank window that appears i inserted the
following code (Thanks to Susan)
Sub DDD()
Dim Qrange As Range
Dim c As Range
Dim WS As Worksheet
Dim rMsg As Range
Set WS = ActiveWorkbook.ActiveSheet
Set Qrange = WS.Range("h8:h107")
For Each c In Qrange
If c.Value = "" Then
'do nothing
ElseIf c.Value = 1 Then
Set rMsg = WS.Range("a" & c.Row)
MsgBox (rMsg & "has only 1 day left to return their book")
ElseIf c.Value = 2 Then
Set rMsg = WS.Range("a" & c.Row)
If MsgBox(" Date has passed for student with candidate #: " &
rMsg & " to return their book " & " Do you want to delete this record?",
vbYesNo _
, "Make a decision.") = vbYes Then
WS.Range("c" & c.Row).ClearContents
WS.Range("e" & c.Row).ClearContents
WS.Range("g" & c.Row).ClearContents
End If
End If
Next c
End Sub
I saved it (clicked on picture of floppy disk), & closed down visual basic.
Back on excel i click on "Macro" in "Developer" tab & run the macro.
i made one of the cells in the q column display 1 or 2 but nothing happens
Did i do something wrong (i made sure macro use is enabled)
can any one help, im not experienced with using visual basic
This is exactly what i have done
I went to the the appropriate worksheet, went to the "Developer" tab &
clicked on "Visual Basic", in the blank window that appears i inserted the
following code (Thanks to Susan)
Sub DDD()
Dim Qrange As Range
Dim c As Range
Dim WS As Worksheet
Dim rMsg As Range
Set WS = ActiveWorkbook.ActiveSheet
Set Qrange = WS.Range("h8:h107")
For Each c In Qrange
If c.Value = "" Then
'do nothing
ElseIf c.Value = 1 Then
Set rMsg = WS.Range("a" & c.Row)
MsgBox (rMsg & "has only 1 day left to return their book")
ElseIf c.Value = 2 Then
Set rMsg = WS.Range("a" & c.Row)
If MsgBox(" Date has passed for student with candidate #: " &
rMsg & " to return their book " & " Do you want to delete this record?",
vbYesNo _
, "Make a decision.") = vbYes Then
WS.Range("c" & c.Row).ClearContents
WS.Range("e" & c.Row).ClearContents
WS.Range("g" & c.Row).ClearContents
End If
End If
Next c
End Sub
I saved it (clicked on picture of floppy disk), & closed down visual basic.
Back on excel i click on "Macro" in "Developer" tab & run the macro.
i made one of the cells in the q column display 1 or 2 but nothing happens
Did i do something wrong (i made sure macro use is enabled)
can any one help, im not experienced with using visual basic