Hi I just posted a similair post about code improvement but with this piece of code I face the similair problem.
The form is for hour administartion). The code basicly checks (before sending the form) if in Range AF19 any hours are put (Value > 0) where the teamnumber is not filled (default value of cell stays on "team" and is not changed to "team1" for instance). Then the cell of team (I19) is selected and marked as red.
So far so good =) However I want to do this same action for AF19 untill AF46. Is there a nice way (working with ranges maybe) to put that in few lines of code. Or do I have to do the below piece of code for every AF Field (So 27 times).
The form is for hour administartion). The code basicly checks (before sending the form) if in Range AF19 any hours are put (Value > 0) where the teamnumber is not filled (default value of cell stays on "team" and is not changed to "team1" for instance). Then the cell of team (I19) is selected and marked as red.
So far so good =) However I want to do this same action for AF19 untill AF46. Is there a nice way (working with ranges maybe) to put that in few lines of code. Or do I have to do the below piece of code for every AF Field (So 27 times).
Code:
Sub SaveSend()
Dim Response As Boolean
If Range("AF19").Value > 0 And Range("I19").Value = "team" Then
Range("I19").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Response = MsgBox("You have not entred the fieldnumber")
Cancel = True
Else
Rest of the code