Hi I have a section of code that I am trying to write a loop for but I am struggling with how to go about it.
This portion of the code runs fine. But I actually have 4 cells which are the ranges, C26, C91, C156 and C221. (See Container 1 comment in code)
I managed to get it to loop, but then my references below (e.g B33,C33,D33,etc.) just write over the top. Is there anyway to write a loop that can increment all of the successive code by the required 65 rows??
I really want to learn how to do this properly rather than copying and pasting 4 times and manually updating the references!
Private Sub RunStabSetup()
' Confirmation of Entry to Form
If MsgBox("Have you double checked your data is correct and ALL test points have been selected before entering on the spreadsheet?", vbYesNo) = vbNo Then Exit Sub
Application.ScreenUpdating = False
Application.Worksheets("Req Sheet").Range("C83") = " "
If Container1CB.Value > "" Then
'Container 1
Application.Worksheets("StabDataCapture").Range("C26") = Container1CB
'60° CheckBox logic statements
If W1T60.Value = True Then Application.Worksheets("StabDataCapture").Range("B33") = "1"
If W1T60.Value = False Then Application.Worksheets("StabDataCapture").Range("B33") = ""
If W2T60.Value = True Then Application.Worksheets("StabDataCapture").Range("C33") = "2"
If W2T60.Value = False Then Application.Worksheets("StabDataCapture").Range("C33") = ""
If W3T60.Value = True Then Application.Worksheets("StabDataCapture").Range("D33") = "3"
If W3T60.Value = False Then Application.Worksheets("StabDataCapture").Range("D33") = ""
If W4T60.Value = True Then Application.Worksheets("StabDataCapture").Range("E33") = "4"
If W4T60.Value = False Then Application.Worksheets("StabDataCapture").Range("E33") = ""
If W5T60.Value = True Then Application.Worksheets("StabDataCapture").Range("F33") = "5"
If W5T60.Value = False Then Application.Worksheets("StabDataCapture").Range("F33") = ""
If W6T60.Value = True Then Application.Worksheets("StabDataCapture").Range("G33") = "6"
If W6T60.Value = False Then Application.Worksheets("StabDataCapture").Range("G33") = ""
If W7T60.Value = True Then Application.Worksheets("StabDataCapture").Range("H33") = "7"
If W7T60.Value = False Then Application.Worksheets("StabDataCapture").Range("H33") = ""
If W8T60.Value = True Then Application.Worksheets("StabDataCapture").Range("I33") = "8"
If W8T60.Value = False Then Application.Worksheets("StabDataCapture").Range("I33") = ""
End If
End Sub
Thanks for you help everyone!
W1T60values keep incrementing too? I assume that you want B33 = 1, C33 = 2, and if we went to like, Z33, you'd want Z33 = 25?