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

¦p¦ó³z¹LVBAÀH¾÷"¸U¤¤¨ú¤@"(¦ý¤£¯à­«½Æ),©â§¹¤@¸U¦¸

¦p¦ó³z¹LVBAÀH¾÷"¸U¤¤¨ú¤@"(¦ý¤£¯à­«½Æ),©â§¹¤@¸U¦¸

¦pÃD,¤p§Ì¥ÎEXCELªº¨ç¼Æ¼g±o¥X¨Ó
¦ý«á¨Óµo²{EXCEL¨ç¼Æ¤Ó¦h¤F(²¦³º¤@¸U­ÓÀx¦s®æ)
³t«×·|Åܦ¨ºC¨ì¤£¦æ

©Ò¥H°²³]D1:D10000³£¬O¤£¦Pªº­È
­n¦p¦ó¨C¦¸³£¬OÀH¾÷¦b³o¤@¸U®æ¸Ì¨ú¤@­Ó­È
³sÄò°õ¦æ¤@¸U¦¸
¦ý³£¤£¯à­«½Æ
ª½¨ì³Ì«á¤@­Ó­È³Q¨ú§¹µ²§ô©O?

PS:¨ú§¹ªº¦P®É²M°£°O¾ÐÅé,¦]¬°¤U¦¸ÁÙ­nÄ~Äò°õ¦æ¦P¼Ëªºµ{¦¡,ÁקK°O¾ÐÅ餣¨¬
¤£¦n·N«ä,³Â·Ð¦U¦ì¥ý¶i¤F...
PKKO

·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

·PÁ¤j¤j,¤p§Ì±Nµ{¦¡§ï½s,¤w¸g¥i¥H¥¿±`¨Ï¥Î,«D±`·P¿E^_^
PKKO

TOP

¦^´_ 3# PKKO


    ¦]¬°§Ú¦b¤½¥q¤£¯à¤W¶Çªþ¥ó,¤p§Ìªþ¤Wµ{¦¡½X¥H¤Î¤½¦¡
    ¦]¬°vbaÁÙ¤£¼ô±xªºÃö«Y,°t¦X¨ç¼Æ¨Ï¥Î= =½Ð§O¨£©Ç

1.¥ý¦bb11ªº¦ì¸m¿é¤J=IFERROR(VLOOKUP(B10,F:F,1,FALSE),"NO")
2.±Ndata©ñ¸m¦bdÄæ
3.°õ¦æ¥¨¶°
  1. Sub test()
  2.    
  3. Application.ScreenUpdating = False
  4.     Dim x As Long
  5.     Dim y As Long
  6.     Columns("F:F").ClearContents
  7.     x = WorksheetFunction.CountA(Range("d:d"))
  8.     i = 1
  9. Do While i <= x
  10.         Randomize  ' ¹ï¶Ã¼Æ²£¥Í¾¹°µªì©l¤Æªº°Ê§@¡C
  11.         y = Int((x - 1 + 1) * Rnd + 1) '¶Ã¼Æ¸¹½X
  12.         Cells(10, 2).Value = Cells(y, 4).Value
  13.     If Cells(11, 2).Value = "NO" Then           '¦pªG­«½Æ«h­«·s¶]¦^°é(i³¡·|+1)
  14.         Cells(i, 6).Value = Cells(10, 2).Value  '¦pªG¨S¦³­«½Æ«h±NDATA©ñ¦bFÄæ
  15.         i = i + 1
  16.     End If
  17. Loop   
  18. End Sub
½Æ»s¥N½X
PKKO

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-8-19 20:16 ½s¿è

¦^´_ 4# PKKO
ÁÙ¦³¥i°Ñ¦Ò¤@¤U
  1. Option Explicit
  2. Sub Ex1()
  3.     Application.ScreenUpdating = True
  4.     Dim i As Long, Msg As Integer
  5.     Randomize  ' ¹ï¶Ã¼Æ²£¥Í¾¹°µªì©l¤Æªº°Ê§@¡C
  6.     For i = 1 To 10000
  7.         Do
  8.             Cells(i, "a") = Int(10000 * Rnd + 1) '¶Ã¼Æ¸¹½X
  9.            Msg = Application.CountIf([a1:a10000], Cells(i, "a"))
  10.            DoEvents
  11.         Loop Until Msg = 1
  12.     Next
  13. End Sub
  14. '******************************
  15. Sub Ex()
  16.     Dim d As Object, y As Integer, A
  17.     Set d = CreateObject("scripting.dictionary")
  18.     Randomize  ' ¹ï¶Ã¼Æ²£¥Í¾¹°µªì©l¤Æªº°Ê§@¡C
  19.     Do
  20.         y = Int(10000 * Rnd + 1)
  21.         d(y) = y
  22.     Loop Until d.Count = 10000
  23.     Range("A1").Resize(10000) = Application.Transpose(d.ITEMS)
  24. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2014-8-19 17:15 ½s¿è

¨Ñ°Ñ¦Ò:
  1. Sub test()  'ÀH¾÷¨ú¥X«ü©w­Ó¼Æªº¤£­«½Æ
  2.   Dim ar, num As Long, r, tmp
  3.   
  4.   ar = [D1:D10000].Value  '­ì©l¸ê®Æ(¥²¶·¬O¤£­«½Æ­È)
  5.   num = 10000 '³]©w¨ú´X­Ó­È
  6.   
  7.   Randomize 'ªì©l¤ÆÀH¾÷¨ç¼ÆRnd()ªººØ¤l  
  8.   For i = 1 To num
  9.     '±qi¨ì³Ì«á¤@µ§¨ú¥X¤@­Ó
  10.     r = Int(Rnd * UBound(ar) - i) + i
  11.     '¨ú¨ìªº´«¨ì«e­±
  12.     tmp = ar(r, 1)
  13.     ar(r, 1) = ar(i, 1)
  14.     ar(i, 1) = tmp
  15.   Next
  16.   
  17.   '¨Ì§Çµ²ªG¨ìFÄæ
  18.   [F1].Resize(num) = ar
  19. End Sub
½Æ»s¥N½X

TOP

¦^´_ 6# stillfish00
  1. r = Int(Rnd * UBound(ar) - i) + i
½Æ»s¥N½X
r¦³¾÷²v¬°0, tmp = ar(r, 1)·|¥X¿ù
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 7# GBKEE
©êºp¡A¤Ö¤F¬A¸¹
r = Int(Rnd * (UBound(ar) - i)) + i

·PÁ«ü¥¿!!

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2014-8-20 09:30 ½s¿è

¦^´_ 7# GBKEE
«ä¼{¤£©P:L  ¡AÀ³¸Ó¬O
r = Int(Rnd * (UBound(ar) - i+1)) + i
  1. Sub test()  'ÀH¾÷¨ú¥X«ü©w­Ó¼Æªº¤£­«½Æ
  2.   Dim ar, num As Long, r, tmp
  3.   
  4.   ar = [D1:D10000].Value  '­ì©l¸ê®Æ(¥²¶·¬O¤£­«½Æ­È)
  5.   num = 10000 '³]©w¨ú´X­Ó­È
  6.   
  7.   Randomize 'ªì©l¤ÆÀH¾÷¨ç¼ÆRnd()ªººØ¤l  
  8.   For i = 1 To num
  9.     '±qi¨ì³Ì«á¤@µ§¨ú¥X¤@­Ó
  10.     r = Int(Rnd * (UBound(ar) - i + 1 )) + i
  11.     '¨ú¨ìªº´«¨ì«e­±
  12.     tmp = ar(r, 1)
  13.     ar(r, 1) = ar(i, 1)
  14.     ar(i, 1) = tmp
  15.   Next
  16.   
  17.   '¨Ì§Çµ²ªG¨ìFÄæ
  18.   [F1].Resize(num) = ar
  19. End Sub
½Æ»s¥N½X

TOP

¦^´_ 9# stillfish00


    ¤j¤j¤Ó¼F®`¤F,§Ú¬Ý¤Fº¡¤[ªºÁÙ¬O¬Ý¤£¬O«ÜÀ´,¬°¦ó¥L¤£·|­«½Æ,¥H¤ÎRESIZEªº¤èªk¬O¦p¦óÀ³¥Îªº

¥i¥H¦A½Ð±Ð±z¤@¤U:

­Y¬OA~CÄæ³£¦U¦³¤@¦Ê®æ¸ê®Æ

§Ú·Q­n¶i¦æ±Æ¦C²Õ¦X,¤]´N¬OA1 & B1 & C1 µM«áA2 & B1 & C1 ¥H¦¹Ãþ±À,¨C­Ó²Õ¦X³£­n¦³¤]´N¬O100*100*100=100¸Uªº²Õ¦X
¦p¦ó¶]³Ì§Ö,§Ú¼gªºµ{¦¡¶]±o¦³ÂI¤[...
PKKO

TOP

        ÀR«ä¦Û¦b : ¡i°±º¢¤£«e¡A²×µL©Ò±o¡j¤H³£°g©ó´M§ä©_ÂÝ¡A¦]¦Ó°±º¢¤£«e¡FÁa¨Ï®É¶¡¦A¦h¡B¸ô¦Aªø¡A¤]¤FµL¥Î³B¡A²×µL©Ò±o¡C
ªð¦^¦Cªí ¤W¤@¥DÃD