- 帖子
- 559
- 主題
- 58
- 精華
- 0
- 積分
- 626
- 點名
- 0
- 作業系統
- win8
- 軟體版本
- office2013
- 閱讀權限
- 50
- 性別
- 男
- 來自
- TW
- 註冊時間
- 2010-11-22
- 最後登錄
- 2024-6-14
|
2#
發表於 2012-4-3 09:17
| 只看該作者
本帖最後由 hugh0620 於 2012-4-3 09:19 編輯
回復 1# luke
用一個最簡單的方式來寫[if]- Sub ex()
- For j = 2 To 4 Step 2 '列數,資料要跑第2&4列
- For i = 1 To 10 '欄位從A到J
- If 30.5 < Cells(j, i) And Cells(j, i) <= 40 Then
- Cells(j + 1, i) = 40 '資料放在第3&5列
- ElseIf 25.5 < Cells(j, i) And Cells(j, i) <= 30.5 Then
- Cells(j + 1, i) = 30
- ElseIf 20.5 < Cells(j, i) And Cells(j, i) <= 25.5 Then
- Cells(j + 1, i) = 25
- ElseIf 16.5 < Cells(j, i) And Cells(j, i) <= 20.5 Then
- Cells(j + 1, i) = 20
- ElseIf 12.1 < Cells(j, i) And Cells(j, i) <= 16.5 Then
- Cells(j + 1, i) = 16
- ElseIf 10.1 < Cells(j, i) And Cells(j, i) <= 12.1 Then
- Cells(j + 1, i) = 12
- ElseIf 8.1 < Cells(j, i) And Cells(j, i) <= 10.1 Then
- Cells(j + 1, i) = 10
- ElseIf 6.1 < Cells(j, i) And Cells(j, i) <= 8.1 Then
- Cells(j + 1, i) = 8
- ElseIf 4.1 < Cells(j, i) And Cells(j, i) <= 6.1 Then
- Cells(j + 1, i) = 6
- ElseIf 2# < Cells(j, i) And Cells(j, i) <= 4.1 Then
- Cells(j + 1, i) = 4
- ElseIf 0 < Cells(j, i) And Cells(j, i) <= 2.1 Then
- Cells(j + 1, i) = 2
- End If
- Next
- Next
- End Sub
複製代碼 |
|