Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21843

Using Command Button to reset excel form

$
0
0
I am trying to create a button which will reset my excel sheet and highlight the cells which need to be selected/edited, whilst ignoring blank cells and formulated cells. At the moment the 1st part of the code works and the validation lists reset, however the 2nd part of the code does not appear to do anything at all. I'm completely new to VB so any help at all would be appreciated.

Sub ResetBox()

Dim r As Range
Dim r1 As Range
Set r = Range("B1").EntireColumn
On Error Resume Next
Set r2 = r.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not r2 Is Nothing Then
For Each Cell In r2
If Cell.Validation.Type = xlValidateList Then
Cell.Value = "--Select--" '< = make sure this matches
End If
Next
Else
MsgBox "No Data Validation Cells"
End If
End Sub

Private Sub CommandButton1_Click(myRange As Range)

Set myRange = Range("B4:B171")

If Cell.Validation.Type = xlValidateList Then
ActiveCell.Interior.ColorIndex = 10
End If

If myRange.Cell.Value = "" Then Exit Sub

If myRange.Cell.HasFormula = True Then Exit Sub

If myRange.Cell.Value > 0 Then
ActiveCell.Interior.ColorIndex = 11
End If

End Sub

Viewing all articles
Browse latest Browse all 21843

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>