私がやりたいことは、予算シートを特定の順序で並べ替えることです。これがまさに私が持っているものです:
列A =予算化する項目の名前(請求書と支払い)
列 B = アイテムの期日。
列 C = アイテムの金額。
VBA
ボタンが押されたときにそれらの列からその情報を取得し、次のように列 B で日ごとに並べ替えるコードを作成したいと思います。
1 - PayDay - 1000
4 - Cell Phone - 75
5 - Mortgage - 1350
編集:
私はこのVBAに取り組んでいました。並べ替え関数を配置する方法を理解する必要があるだけで、結果が日の列で並べ替えられます。
Sub CreateList()
' Clear the current records
currentRow = 2
While currentRow < 200
If IsEmpty(Worksheets("Jan").Cells(currentRow, 9)) Then
GoTo Generate
End If
Worksheets("Jan").Cells(currentRow, 9).Value = ""
Worksheets("Jan").Cells(currentRow, 10).Value = ""
Worksheets("Jan").Cells(currentRow, 11).Value = ""
Worksheets("Jan").Cells(currentRow, 12).Value = ""
currentRow = currentRow + 1
Wend
Generate:
' Generate new list
titleCol = 1
dayCol = 2
amountCol = 3
currentListRow = 2
currentSheet = 1
While currentSheet < 2
currentRow = 7
cellVal = ""
While currentRow < 800
cellVal = Worksheets("Jan").Cells(currentRow, dayCol).Text
If Not IsEmpty(cellVal) Then
If Not cellVal = "0" Then
If Not cellVal = "" Then
If Not cellVal = "Due Date" Then
' Set vals in list cells
Worksheets("Jan").Cells(currentListRow, 10).Value = Worksheets("Jan").Cells(currentRow, dayCol).Text
Worksheets("Jan").Cells(currentListRow, 9).Value = Worksheets("Jan").Cells(currentRow, titleCol).Text
Worksheets("Jan").Cells(currentListRow, 11).Value = Worksheets("Jan").Cells(currentRow, amountCol).Text
currentListRow = currentListRow + 1
End If
End If
End If
End If
currentRow = currentRow + 1
Wend
currentSheet = currentSheet + 1
Wend
End Sub