Sub 将所有列全部转换为文本() t=timer 'Cells(Rows.Count, 1).End(xlUp).Row 获取第一列最后一个非空单元格的行号 s = Cells(, Columns.Count).End(xlToLeft).Column '获取第一行最后一个非空单元格的列号 For i = To s Columns(i).Select Selection.TextToColumns Destination:=Cells(, i), DataType:=xlDelimited,
Sub W() ' MsgBox "行数:" & Selection.Rows.Count Dim rows_count As Integer Dim rows_id As Integer Dim column_count As Integer column_count = Selection.Columns.Count '获取选择区域的列数 'MsgBox column_count '打印列数 rows_id = ActiveCell.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) '可以直接sub(),不然选择就会触发vba Dim rows_count As Integer Dim rows_id As Integer Dim column_count As Integer Dim column_id As Integer column_count = Selection.Columns.Count '返回选择区域列数
使用VBA对指定的单元格赋值并填充颜色 ====================================================== 代码区域 ====================================================== Sub row应用() For Each rw In Rows("1:13") = Then rw.Interior.ColorIndex = rw.Value = End If Next End Sub 效果如下图:
单元格内设置了有效性,通过VBA怎么去复制呢?代码如下: Public Sub 复制单元格批注() Dim range1 As range Dim range2 As range '清除G列 Columns("G:G").Clear Set range1 = range("A1:A2") '指定要复制的单元格区域 Set range2 = range("D1") '指定要复制的位置(左上角单元格 range1.Copy range2.PasteS