T
TyeJae
I have to go up to 20 on my If statement here and was wondering if ther
was a way to shorten this in VBA.
Example:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C6").Value = 0 Then
Range("M6:AF6").Value = "-"
End If
If Range("C7").Value = 0 Then
Range("M7:AF7").Value = "-"
End If
If Range("C8").Value = 0 Then
Range("M8:AF8").Value = "-"
End If
If Range("C9").Value = 0 Then
Range("M9:AF9").Value = "-"
End If
If Range("C10").Value = 0 Then
Range("M10:AF10").Value = "-"
End If
If Range("C11").Value = 0 Then
Range("M11:AF11").Value = "-"
End If
If Range("C12").Value = 0 Then
Range("M12:AF12").Value = "-"
End If
If Range("C13").Value = 0 Then
Range("M13:AF13").Value = "-"
End If
If Range("C14").Value = 0 Then
Range("M14:AF14").Value = "-"
End If
If Range("C15").Value = 0 Then
Range("M15:AF15").Value = "-"
End If
If Range("C16").Value = 0 Then
Range("M16:AF16").Value = "-"
End If
If Range("C17").Value = 0 Then
Range("M17:AF17").Value = "-"
End If
If Range("C18").Value = 0 Then
Range("M18:AF18").Value = "-"
End If
End Sub
Hopefully there is, otherwise I am going to be busy.
-TyeJae
was a way to shorten this in VBA.
Example:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C6").Value = 0 Then
Range("M6:AF6").Value = "-"
End If
If Range("C7").Value = 0 Then
Range("M7:AF7").Value = "-"
End If
If Range("C8").Value = 0 Then
Range("M8:AF8").Value = "-"
End If
If Range("C9").Value = 0 Then
Range("M9:AF9").Value = "-"
End If
If Range("C10").Value = 0 Then
Range("M10:AF10").Value = "-"
End If
If Range("C11").Value = 0 Then
Range("M11:AF11").Value = "-"
End If
If Range("C12").Value = 0 Then
Range("M12:AF12").Value = "-"
End If
If Range("C13").Value = 0 Then
Range("M13:AF13").Value = "-"
End If
If Range("C14").Value = 0 Then
Range("M14:AF14").Value = "-"
End If
If Range("C15").Value = 0 Then
Range("M15:AF15").Value = "-"
End If
If Range("C16").Value = 0 Then
Range("M16:AF16").Value = "-"
End If
If Range("C17").Value = 0 Then
Range("M17:AF17").Value = "-"
End If
If Range("C18").Value = 0 Then
Range("M18:AF18").Value = "-"
End If
End Sub
Hopefully there is, otherwise I am going to be busy.
-TyeJae