ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

½Ð°Ý³sµ²¥t¤@­ÓÀɮפ£­n¥´¶}

½Ð°Ý³sµ²¥t¤@­ÓÀɮפ£­n¥´¶}

¤p§Ì¦³AÀÉ®×·Qª½±µÅª¨úBÀɮצp¹Ï

­ì¥»¦b2007¥i¥H°õ¦æ
¦b2003«K·|¦³°ÝÃD¤F
¦Ó¥BRUNªº®É­ÔBÀÉ®×·|¥´¶}
¥i¥H¤£­nÅý¥¦¥´¶}
§ï¥Î«ö¶s«ö¤F¤~°õ¦æ¶Ü
¥t¥~§Ú·Q¬Û¦Pªº²£«~¼Æ¶q¥[Á`Åã¥Ü¤@¦¸´N¦n¦p¹Ï

½Ð«üÂI¤@¤U¡AÁÂÁ Test.rar (57.91 KB)
Private Sub Workbook_Open()
Dim Wb As Workbook
Set Wb = Workbooks.Open("C:\Documents and Settings\123\®à­±\Test\B.xls")
For i = 1 To 30
ThisWorkbook.Worksheets("Sheet1").Cells(2, 4 * i - 2) = Wb.Worksheets("Sheet1").Cells(i + 3, 1).Value
If (Wb.Worksheets("Sheet1").Cells(i, 2).Value) Mod 100 = 0 Then
ThisWorkbook.Worksheets("Sheet1").Cells(3, 4 * i - 2) = "(¥Ø¼Ð " & (Wb.Worksheets("Sheet1").Cells(i + 3, 2).Value) / 1000 & "k)"
Else
ThisWorkbook.Worksheets("Sheet1").Cells(3, 4 * i - 2) = "(¥Ø¼Ð " & (Wb.Worksheets("Sheet1").Cells(i + 3, 2).Value) & "units)"
End If
Next
End Sub
50 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

¥»©«³Ì«á¥Ñ GBKEE ©ó 2010-10-5 09:17 ½s¿è

¦^´_ 1# amu1129
§Aªº¿ù»~¬O If (Wb.Worksheets("Sheet1").Cells(i+3, 2).Value) Mod 100 = 0 Then ¨S¦³¥[3 ¨ä¥L³£¦³¥[3
ÀÉ®×¥²¶·¬O¶}±Òªº ¤~¥i¥H°õ¦æ. ©óµ{¦¡³Ì«áÃö³¬±¼´N¥i¥H
¦p­n¥Î«ö¶s°õ¦æ  ½Ð §R±¼Sub Workbook_Open ªºµ{¦¡  ±Nµ{¦¡½X½Æ»s¨ì «ö¶sªºµ{¦¡¸Ì
¥t¥~§Ú·Q¬Û¦Pªº²£«~¼Æ¶q¥[Á`Åã¥Ü¤@¦¸´N¦n µ{¦¡½X¦p¤U:
  1. Private Sub Workbook_Open()
  2. Dim Wb As Workbook, d As Object, i%, ii%
  3. Set Wb = Workbooks.Open("C:\Documents and Settings\123\®à­±\Test\B.xls")
  4. Set d = CreateObject("Scripting.Dictionary")
  5. For i = 1 To 30
  6. If d.exists(Wb.Worksheets("Sheet1").Cells(i + 3, 1).Value) = False And Wb.Worksheets("Sheet1").Cells(i + 3, 1) <> "" Then
  7. d(Wb.Worksheets("Sheet1").Cells(i + 3, 1).Value) = ""
  8. ii = ii + 1
  9. ThisWorkbook.Worksheets("Sheet1").Cells(2, 4 * ii - 2) = Wb.Worksheets("Sheet1").Cells(i + 3, 1).Value
  10. If (Wb.Worksheets("Sheet1").Cells(i + 3, 2).Value) Mod 100 = 0 Then
  11. ThisWorkbook.Worksheets("Sheet1").Cells(3, 4 * ii - 2) = "(¥Ø¼Ð " & (Wb.Worksheets("Sheet1").Cells(i + 3, 2).Value) / 1000 & "k)"
  12. Else
  13. ThisWorkbook.Worksheets("Sheet1").Cells(3, 4 * ii - 2) = "(¥Ø¼Ð " & (Wb.Worksheets("Sheet1").Cells(i + 3, 2).Value) & "units)"
  14. End If
  15. End If
  16. Next
  17. Wb.Close 'Ãö³¬ÀÉ®×
  18. End Sub
½Æ»s¥N½X

TOP

ª©¥D~¤£¦n·N«ä
§Ú¤£¤ÓÀ´ii = ii + 1³o¬qªº¥Îªk­C
§Ú³v¬q°õ¦æ¤j­Pª¾¹D¬O±N­«½Æªº²£«~¦X¤@
¦ý¬O·Q§ó²M·¡¬°¦ó³o¼Ë¥i¥H¦X¨Ö
·Ð½Ðª©¥DÀ°§Ú«üÂI¡AÁÂÁÂ
50 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_ 3# amu1129
If d.exists(Wb.Worksheets("Sheet1").Cells(i + 3, 1).Value) = False And Wb.Worksheets("Sheet1").Cells(i + 3, 1) <> "" Then
·í¤W­±ªºµ{¦¡½X ¬°¦b§PÂ_²£«~¥¼¥X²{®Éªº±ø¥ó¦¨¥ß®É  °õ¦æ¤U­±µ{¦¡½X
d(Wb.Worksheets("Sheet1").Cells(i + 3, 1).Value) = ""
ii = ii + 1   
·í²Ä¤@¦¸°õ¦æii = ii + 1 ®É ¥Ñ©óµ{¦¡¥¼©ó¶}©l®É«ü©w­Èµ¹ÅÜ¼Æ i, ¦¹®Éii¬°ªÅ¥Õªº(EMPTY)  ©Ò¥H ii = ªÅ¥Õ + 1=>1
¤U¤@¦¸ §PÂ_²£«~¥¼¥X²{®Éªº±ø¥ó¦¨¥ß®É  ii = ii (1) + 1 =>2
ThisWorkbook.Worksheets("Sheet1").Cells(2, 4 * ii - 2) = Wb.Worksheets("Sheet1").Cells(i + 3, 1).Value
¦p¦¹ 4 * ii - 2 ­pºâªº­È¤~·|¥¿½T

TOP

        ÀR«ä¦Û¦b : ÁÀ¨¥¹³¤@¦·²±¶}ªºÂAªá¡A¥~ªí¬üÄR¡A¥Í©Rµu¼È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD