我正在尝试此代码
row = 2
With Summary
.Range("$A$1:$A$100").RemoveDuplicates Columns:=1, Header:=xlYes
For row To .Rows.Count
.Cells(row, 2) = 1
row = row + 1
Next row
End With
但是我在for循环语句中遇到语法错误
这应该怎么样?
答案 0 :(得分:1)
您不需要Loop
:
Sub dural()
Dim N As Long, summary As Worksheet
Set summary = ActiveSheet
With summary
.Range("$A$1:$A$100").RemoveDuplicates Columns:=1, Header:=xlYes
N = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("B2:B" & N).Value = 1
End With
End Sub
注意: 该代码假定列 A 中没有其他内容。