Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub ComboBox1_Change()
- If ComboBox1.Value = "Yes" Then
- 'While loop: Iterate from N14-NXX looking for multiple whitespaces
- 'in a row in the OXX column then exit loop.
- 'Initialize search variables
- loopDone = False
- currentRow = 14
- testCol = 15
- baseCol = 14
- whitespaceCount = 0
- 'Iterate
- Do While loopDone = False
- 'Check for whitespace
- If Cells(currentRow, testCol).Value <> "" Then
- 'No whitespace - reset whitespaceCount
- whitespaceCount = 0
- 'Set value of current cell to 0.45, and lock
- Cells(currentRow, baseCol).Value = 0.45
- Cells(currentRow, baseCol).Locked = True
- Else
- 'Found whitespace - increment whitespaceCount
- whitespaceCount = whitespaceCount + 1
- 'Check number of whitespaces in a row
- If whitespaceCount > 1 Then
- 'More than 1 whitespace in a row -
- 'Protect the sheet then exit loop
- Sheet1.Protect AllowInsertingRows:=True
- loopDone = True
- End If
- End If
- 'Increment current row
- currentRow = currentRow + 1
- Loop
- ElseIf ComboBox1.Value = "No" Then
- 'While loop: Iterate from N14-NXX looking for multiple whitespaces
- 'in a row in the OXX column then exit loop.
- 'Initialize search variables
- loopDone = False
- currentRow = 14
- testCol = 15
- baseCol = 14
- whitespaceCount = 0
- 'Unprotect the sheet prior to the loop
- Sheet1.Unprotect
- 'Iterate
- Do While loopDone = False
- 'Check for whitespace
- If Cells(currentRow, testCol).Value <> "" Then
- 'No whitespace - reset whitespaceCount
- whitespaceCount = 0
- 'Set value of current cell to 0.35, and unlock
- Cells(currentRow, baseCol).Value = 0.35
- Cells(currentRow, baseCol).Locked = False
- Else
- 'Found whitespace - increment whitespaceCount
- whitespaceCount = whitespaceCount + 1
- 'Check number of whitespaces in a row
- If whitespaceCount > 1 Then
- 'More than 1 whitespace in a row - exit loop
- loopDone = True
- End If
- End If
- 'Increment current row
- currentRow = currentRow + 1
- Loop
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement