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

[µo°Ý] VBA ¹Bºâ«á¦Û°Ê´«¦æ

[µo°Ý] VBA ¹Bºâ«á¦Û°Ê´«¦æ

½Ð±Ð¦U¦ì¥ý¶i,¤p§Ì¥¿¦b°µ¼ÒÀÀÅçÃÒ,¨Ï¥Î¶Ã¼Æ²£¥Í¾¹²£¥Í¼Æ¾Ú¶i¦æ¼ÒÀÀÅçÃÒ,

§Ú¦bVBA¤W¼g¤F¤@¬qµ{¦¡²£¥Í¤F¥¨¶°«ö¶s¥i¥H¦bA1:A7²£¥Í¤@¶gªº¶Ã¼Æ,¥i¬O

§Ú·Q­n¦b¨C«ö¤@¦¸¥¨¶°«ö¶s´N¦A¦Û°Ê©¹¤U²£¥Í¤@¶g(A8:A14)ªº¶Ã¼Æ¸Ó¦p¦ó

½s¼g©O?

Sub Project1_Click()
Dim rTar As Range

Randomize
For Each rTar In Range("A1:A7")
rTar = Int((21 - 1) * Rnd + 1) * 0.01
Next
End Sub
¤p¤B

¦^´_ 5# a5007185

¦pªG³Ì«á¤@®æ«DªÅ, ©¹¤U²¾¤@®æ
set xEnd=xEnd.CELLS(2, 1)  »P³o­Ó·N«ä¬Û¦P
¤]¥i¥H set xEnd=xEnd(2, 1)

¦PÄæ, ©Ò¥H¥i¬Ù²¤²Ä¤G°Ñ¼Æ

TOP

  1. Sub Project1_Click()
  2. Dim rTar As Range, r&
  3. r = Cells(Rows.Count, 1).End(3).Row
  4. If Not r = 1 Then r = r + 1
  5. Randomize
  6. For Each rTar In Cells(r, 1).Resize(7)
  7. rTar = Int((21 - 1) * Rnd + 1) * 0.01
  8. Next
  9. End Sub
½Æ»s¥N½X

TOP

¦^´_ 4# ­ã´£³¡ªL

½Ð°Ý³o¥y»yªkªº¥Î·N¬O¤°»ò¡H
  1. set xEnd=xEnd(2)
½Æ»s¥N½X
xEnd(2)ªº°Ñ¼Æ·½¦Û­þ¸Ì¡H

ÁÂÁ«ü±Ð¡ã

TOP

dim xEnd as range, xR as range
set xEnd=cells(rows.count,1).end(xlup)
if xEnd<>"" then set xEnd=xEnd(2)
for each xR in xEnd.resize(7)
    xR=???
next

TOP

¦^´_ 1# PaulDing

°Ñ¦Ò¬Ý¬Ý
  1. Sub Project1_Click()

  2. Dim rTar As Range

  3. Randomize
  4. For Each rTar In Range("A1:A7").Offset(IIf(Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row = 1, IIf(Cells(1, 1) = "", 0, 1), Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row))
  5. rTar = Int((21 - 1) * Rnd + 1) * 0.01
  6. Next

  7. End Sub   
½Æ»s¥N½X

TOP

¦^´_ 1# PaulDing


¦pªG§A­n¼W¥[§Aªº¶Ã¼Æ½d³òªº¸Ü¡A
§A¥i¥H­×§ïFor°j°éªº½d³ò¡A
For Each rTar In Range("A1:A7")
  1. For Each rTar In Range("A1:A14")
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : «Ý¤H°h¤@¨B¡A·R¤H¼e¤@¤o¡A´N·|¬¡±o«Ü§Ö¼Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD