如何创建一个宏,在两个不同的工作表中将学生ID分为两列,并将其值更改为新的序列号?
答案 0 :(得分:0)
我创建了代码并且它可以正常工作
Sub Macro13()
Dim i As Long
Dim myValue1 As Double, myValue2 As Double, seqNo As Double
LastRow = ActiveSheet.UsedRange.Cells(ActiveSheet.UsedRange.Rows.Count, 1).Row
seqNo = 1
For i = 2 To LastRow
myValue1 = Worksheets("Sheet2").Range("D" & i).Value
myValue2 = Worksheets("Sheet1").Range("B" & i).Value
If myValue1 = myValue2 Then
Worksheets("Sheet2").Range("D" & i).Value = seqNo
Worksheets("Sheet1").Range("B" & i).Value = seqNo
seqNo = seqNo + 1
End If
Next i
End Sub