Private Sub CommandButton21_Click()
For i = 1 To 100
If Len(Cells(i, 1)Text) = 0 Then
Cells(i, 1)InteriorColor = RGB(255, 255, 0)
End If
Next
End Sub
加个按钮,双击粘贴进去,我这是对第一列,第几列你自己改 如果多列加个for循环
这个用条件格式就能搞定,干嘛写VBA啊
写一个SUB来更新吧,程序代码如下:
程序代码为:
Sub 更新名单()
Dim arr, list$(1 To 100, 1 To 1), i&, j&, n&, nm$, st As Worksheet
For Each st In Worksheets
If Len(stName) = 1 Then '单字母名称的表为清单表
arr = stUsedRange
For i = 6 To UBound(arr)
nm = Trim(arr(i, 1))
If nm <> "" Then
For j = 1 To n
If list(j, 1) = nm Then Exit For
Next j
If j > n Then
n = n + 1
list(n, 1) = nm
End If
End If
Next i
End If
Next st
With MeRange("B5")Resize(n, 1)
Select
Value = list
End With
End Sub
如果愿意,也可以设置工作表的Change事件来自动修改月统计表的名单,看起来那样高级一点。
Private Sub Form_Load()
With MSFlexGrid1
FixedCols = 0
FixedRows = 0
Rows = 10
Cols = 10
End With
End Sub
Private Sub MSFlexGrid1_Click()
With MSFlexGrid1
x = Row
y = Col
CellBackColor = vbYellow
Row = x
Col = 0
CellBackColor = vbYellow
Row = 0
Col = y
CellBackColor = vbYellow
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim g As Range
Set g = Intersect(Target, Range("A1:N36")) '获取交集区域g
If g Is Nothing Then Exit Sub '如果交集为空则退出sub
If gCount > 1 Then '如果g区域包含多个单元格
gInteriorColor = xlNone '那么设置g的背景色为无色
Else '否则,即g只有一个单元格
If gInteriorColor = vbRed Then '如果g的背景色是红色
gInteriorColor = xlNone '那么设置为无色
Else
gInteriorColor = vbRed '否则设置为红色
End If
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)