作者:乔山办公网日期:
返回目录:excel表格制作
Sub sdk()
i = 1
For Each sc In Selection
sc.Value = i
i = i + 1
Next
End Sub
Range("a1").End(xlDown).Offset(1, 0).Activate
要看你源数据连续不连续,如果连续,这个公式没问题,不连续就不起作用
你好!楼主想要的VBA程序代码,其程序代码如下:
Sub ColorInset()
Dim i1, i2, i3
On Error Resume Next '忽略运行copy过程中可能出现的错误
Set mysheet1 = ThisWorkbook.Worksheets("Sheet1") '定义工作表
For i1 = 2 To 1000 '从第2行到1000行
If mysheet1.Cells(i1, 1) <> "" Then '如果A列单元格不zd是空白,则
For i2 = 2 To 6 '从第2列到第6列
If mysheet1.Cells(i1, 1) = mysheet1.Cells(i1, i2) Then '如果两个单元格的内容相同
mysheet1.Cells(i1, 1).Interior.Color = RGB(255, 255, 0) '填充黄颜色
mysheet1.Cells(i1, i2).Interior.Color = RGB(255, 255, 0)
End If
Next
End If
Next
End Sub
程序运行之后的结果如下:
Sub 选取()
Dim arry
y = Range("m65536").End(xlUp).Row
For i = 2 To y
If Cells(i, "m").Value = "★" Then
If IsEmpty(arry) Then
Set arry = Range("m" & i)
Else
Set arry = Union(arry, Range("m" & i))
End If
End If
Next
arry.Select
End Sub