sunshine076
Registered User.
- Local time
- Today, 03:07
- Joined
- Apr 6, 2009
- Messages
- 160
Is there a way to modify the if statements to help reduce the cluttered mess for the if statements. I am going to be adding more if statements to compensate for more data. Below is the program that I currently have:
Private Sub process(ByVal myRow As Integer, myCol As Integer)
Dim ce As String
Dim AA As Range
Dim d As Integer
Dim e As Integer
Dim BB As Range
d = 4
ce = "y"
Application.EnableEvents = False
ActiveSheet.Unprotect Password:=P
Do
Set AA = Range(Cells(8, d), Cells(1000, d))
Cells(4, d).Value = Application.WorksheetFunction.CountIf(AA, ce)
d = d + 1
Loop Until d = 12
Set AA = Nothing
If Cells(4, 4) > 0 Then Cells(5, 4).Value = Cells(3, 2).Value / Cells(4, 4).Value / 100
If Cells(4, 5) > 0 Then Cells(5, 5).Value = Cells(3, 2).Value / Cells(4, 5).Value / 100
If Cells(4, 6) > 0 Then Cells(5, 6).Value = Cells(3, 2).Value / Cells(4, 6).Value / 100
If Cells(4, 7) > 0 Then Cells(5, 7).Value = Cells(3, 2).Value / Cells(4, 7).Value / 100
If Cells(4, 8) > 0 Then Cells(5, 8).Value = Cells(3, 2).Value / Cells(4, 8).Value / 100
If Cells(4, 9) > 0 Then Cells(5, 9).Value = Cells(3, 2).Value / Cells(4, 9).Value / 100
If Cells(4, 10) > 0 Then Cells(5, 10).Value = Cells(3, 2).Value / Cells(4, 10).Value / 100
If Cells(4, 11) > 0 Then Cells(5, 11).Value = Cells(3, 2).Value / Cells(4, 11).Value / 100
ActiveSheet.Protect Password:=P
Application.EnableEvents = True
End Sub
Private Sub process(ByVal myRow As Integer, myCol As Integer)
Dim ce As String
Dim AA As Range
Dim d As Integer
Dim e As Integer
Dim BB As Range
d = 4
ce = "y"
Application.EnableEvents = False
ActiveSheet.Unprotect Password:=P
Do
Set AA = Range(Cells(8, d), Cells(1000, d))
Cells(4, d).Value = Application.WorksheetFunction.CountIf(AA, ce)
d = d + 1
Loop Until d = 12
Set AA = Nothing
If Cells(4, 4) > 0 Then Cells(5, 4).Value = Cells(3, 2).Value / Cells(4, 4).Value / 100
If Cells(4, 5) > 0 Then Cells(5, 5).Value = Cells(3, 2).Value / Cells(4, 5).Value / 100
If Cells(4, 6) > 0 Then Cells(5, 6).Value = Cells(3, 2).Value / Cells(4, 6).Value / 100
If Cells(4, 7) > 0 Then Cells(5, 7).Value = Cells(3, 2).Value / Cells(4, 7).Value / 100
If Cells(4, 8) > 0 Then Cells(5, 8).Value = Cells(3, 2).Value / Cells(4, 8).Value / 100
If Cells(4, 9) > 0 Then Cells(5, 9).Value = Cells(3, 2).Value / Cells(4, 9).Value / 100
If Cells(4, 10) > 0 Then Cells(5, 10).Value = Cells(3, 2).Value / Cells(4, 10).Value / 100
If Cells(4, 11) > 0 Then Cells(5, 11).Value = Cells(3, 2).Value / Cells(4, 11).Value / 100
ActiveSheet.Protect Password:=P
Application.EnableEvents = True
End Sub