當前位置:編程學習大全網 - 編程軟體 - 請OFFICE VBA 高手幫助編寫“宏”?

請OFFICE VBA 高手幫助編寫“宏”?

A列sn,B列kuandu,C列gaodu,D列shuliang。

第壹行標題,數據從第2行開始。

Sub Macro1()

Dim r As Long

Dim i As Long

Dim spec1 As New Collection

Dim spec2 As New Collection

Dim temp

Dim str1 As String

Dim row0 As Integer

On Error Resume Next

r = Range("A65536").End(xlUp).Row

For i = 2 To r

temp = Cells(i, 2)

If temp > Cells(i, 3) Then

Cells(i, 2) = Cells(i, 3)

Cells(i, 3) = temp

End If

str1 = Str(temp)

spec1.Add Cells(i, 3), str1

If Err.Number = 457 Then

Err.Clear

row0 = spec2(str1)

Cells(row0, 1) = Cells(row0, 1) & "&" & Cells(i, 1)

Cells(row0, 4) = Cells(row0, 4) + Cells(i, 4)

Rows(i).Delete

i = i - 1

Else

spec2.Add i, str1

End If

If Cells(i, 1) = "" Then Exit For

Next i

For i = 1 To spec1.Count

spec1.Remove 1

spec2.Remove 1

Next i

End Sub

  • 上一篇:全國非計算機專業計算機二級考什麽
  • 下一篇:求解釋這條語句的含義return t>a[n-1]?t:a[n-1],下面這道題詳細求解過程是什麽?
  • copyright 2024編程學習大全網