If Target.Column = 8 Then //如果点击的是是第8列
Dim i As Integer // i 为整型
For i = 1 To 455 //循环语句 从 1到455
Cells(i, 8).Value = Cells(i, 8).Value //单元格(行,列)的值 = 单元格(行,列)的值。此处主要是为了把字符串格式转为数值格式。运行前将此列单元格设置为数值。
Next
End If
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 1 Then
Dim j As Integer
For j = 3 To 155
If Cells(j, 1).Value = "" Then
Cells(j, 1).Value = Cells(j - 1, 1).Value // 让后一行单元格等于上一行单元格的值
End If
Next
End If
If Target.Column = 4 Then
Dim i As Integer
For i = 1 To 155
Cells(i, 4).Value = Cells(i, 4).Value
Next
End If
End Sub
此代码执行结果就是将单元格左上角的三角符号去掉(在设置单元格为数值不起作用的时候)。
打开代码编辑器快捷键 ALT+F11
这篇博客介绍了如何使用VBA宏代码在Excel中删除第一列和第四列单元格左上角的三角符号。通过在Worksheet_BeforeDoubleClick事件中检查目标列,并对特定列进行迭代更新,实现符号的移除。当设置单元格为数值无效时,此方法尤其有用。
4514

被折叠的 条评论
为什么被折叠?



