- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 247
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-11-14
|
¥»©«³Ì«á¥Ñ Hsieh ©ó 2010-9-29 22:33 ½s¿è
- Private Sub CommandButton1_Click()
- r = Application.CountA(Columns("A")) + 1
- Sheets("sheet1").Cells(r, 1) = "¶R"
- Randomize
- Sheets("sheet1").Cells(r, 2) = Int((10 * Rnd) + 1)
- Buy_Sale
- End Sub
- Private Sub CommandButton2_Click()
- r = Application.CountA(Columns("A")) + 1
- Sheets("sheet1").Cells(r, 1) = "½æ"
- Randomize
- Sheets("sheet1").Cells(r, 2) = Int((10 * Rnd) + 1)
- Buy_Sale
- End Sub
- Sub Buy_Sale()
- Dim Sale, Buy, A As Range, s&, k&
- Set Sale = CreateObject("Scripting.Dictionary")
- Set Buy = CreateObject("Scripting.Dictionary")
- For Each A In Range([A1], [A65536].End(xlUp))
- Select Case A.Value
- Case "¶R"
- If Sale.Count > 0 Then
- A.Offset(, 2) = Sale(s) - A.Offset(, 1)
- Sale.Remove s
- s = s + 1
- Else
- Buy(s) = A.Offset(, 1)
- A.Offset(, 2) = ""
- s = s + 1
- End If
- Case "½æ"
- If Buy.Count > 0 Then
- A.Offset(, 2).Value = A.Offset(, 1) - Buy(k)
- Buy.Remove k
- k = k + 1
- Else
- Sale(k) = A.Offset(, 1)
- A.Offset(, 2) = ""
- k = k + 1
- End If
- End Select
- Next
- End Sub
½Æ»s¥N½X |
|