我想要做的是拿我的預算表並按特定順序排序。這正是我:Excel創建基於其他單元格的分類列表
列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
嘗試錄製一個宏來做你所需要的。 –
你還沒有詳細描述需要在你的問題中複製和粘貼什麼內容 - 但是從你的代碼看來,你想要移動一些數據 – whytheq