I am relatively new to using Excel VBA. I created an analysis tool for an assessment in school so that the teachers workload could be reduced. The spreadsheet got far too large and due to the multiple scenarios needed and conditional formatting the spreadsheet became slow and problematic.
I have a Private Sub worksheet_change (ByVal Target As Range)
as follows which works.
Private Sub Worksheet_Change(ByVal Target As Range)
If (Cells(3, Target.Column) = "AUT" Or Cells(3, Target.Column) = "SPR" Or Cells(3, Target.Column) = "SUM") And Target.Column >= 1 And Target.Row >= 4 And Target.Row <= 500 Then
If Cells(Target.Row, "M").Value = "MLD" And Cells(Target.Row, "ET").Value = 1 And Cells(Target.Row, Target.Column - 1) = 2 Then
Call Year1Start
End If
End If
End Sub
I've tried to create a Sub
procedure but to no avail:
Sub Year1Start()
If Cells(Target.Row, "EM").Value = 0.4 Then
Call Y1StartY2DataEntry040
End If
End Sub
Sub Y1StartY2DataEntry040()
'check the various outputs for year 1 start with year 2 data entry:
'y1=0.4 R0.42,Y0.44,G0.46, B0.48
ActiveCell.Offset(0, 1).Select
If ActiveCell.Value < 0.44 Then
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "R"
ActiveCell.Offset(0, -2).Select
ActiveCell.Interior.Color = RGB(255, 0, 0)
ActiveCell.Offset(0, 1).Select
End If
If ActiveCell.Value = 0.44 Then
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "Y"
ActiveCell.Offset(0, -2).Select
ActiveCell.Interior.Color = RGB(255, 255, 51)
ActiveCell.Offset(0, 1).Select
End If
If ActiveCell.Value = 0.46 Then
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "G"
ActiveCell.Offset(0, -2).Select
ActiveCell.Interior.Color = RGB(51, 225, 51)
ActiveCell.Offset(0, 1).Select
End If
If ActiveCell.Value >= 0.48 Then
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "B"
ActiveCell.Offset(0, -2).Select
ActiveCell.Interior.Color = RGB(55, 142, 225)
ActiveCell.Offset(0, 1).Select
End If
If ActiveCell.Value = isblank Then
ActiveCell.Offset(0, -1).Select
ActiveCell.Interior.ColorIndex = 0
ActiveCell.Offset(0, 2).Select
ActiveCell.Value = ""
ActiveCell.Offset(0, -2).Select
End If
End Sub
Basically I need to check to see if the value is true then it calls a new procedure.
I need to do it this way because I got procedure too large before.