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

VBA ª«¥ó¿ï¨ú¼gªk°ÝÃD

VBA ª«¥ó¿ï¨ú¼gªk°ÝÃD

½Ð°Ý¦U¦ì¤j¤j
  1. Sub test()

  2. Dim a As Worksheet
  3. Dim b As Worksheet

  4. Set a = Sheets("¤u§@ªí1")
  5. Set b = Sheets("¤u§@ªí2")

  6. For i = 0 To 2

  7. a.Select
  8. Range(Cells(i + 2, 2), Cells(i + 2, 6)).Copy

  9. b.Select
  10. Cells(i * 9 + 2, 2).Select
  11. Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
  12. Next

  13. End Sub
½Æ»s¥N½X
§Ú§â
a.Select
Range(Cells(i + 2, 2), Cells(i + 2, 6)).Copy ³o¬qÁY¼g
a.Range(Cells(i + 2, 2), Cells(i + 2, 6)).Copy ¬°¤°»ò¥L·|¸õ¥X¿ù»~?
¬¡­¶Ã¯1.rar (17.18 KB)

¥»©«³Ì«á¥Ñ n7822123 ©ó 2020-6-19 23:22 ½s¿è

¦^´_ 1# mash071896

Set a = Sheets("¤u§@ªí1")
Set b = Sheets("¤u§@ªí2")

§Ú§â
a.Select
Range(Cells(i + 2, 2), Cells(i + 2, 6)).Copy ³o¬qÁY¼g
a.Range(Cells(i + 2, 2), Cells(i + 2, 6)).Copy ¬°¤°»ò¥L·|¸õ¥X¿ù»~?   

¦pªG§A²{¦b·í«eªºªí®æ¬O "¤u§@ªí2"¡A§A°õ¦æ¤U­±³o¦æ¡A¥»¨Ó´N¬O¦³°ÝÃD
Sheets("¤u§@ªí1").Range(Cells(i + 2, 2), Cells(i + 2, 6)).Copy

³o´N­n»¡©ú ¡A¦b·í«eª«¥ó¤U¡A¥i¥H¬Ù²¤«e­±¤÷ª«¥óªº±Ô­z
¤µ¤Ñ§A¦b"¤u§@ªí2"·í¤U¡A¼g¤F³o¤@¦æµ{¦¡

Range("A1")="123"

¨t²Î·|¦b·í«e¬¡­¶Ã¯ªº·í«e¤u§@ªíªº[A1]Äæ¦ì¶ñ­È¡A¤]´N¬Û·í©ó¤U­±³o¦æ
Workbooks("§Aªº¬¡­¶Ã¯.xlsx").Sheets("¤u§@ªí2").Range("A1")="123"

¤]´N¬O»¡§A¥u¼g¤F Range("A1")="123"¡A¦ý¬O¨t²Î¦Û°ÊÀ°§A§â"¤÷ª«¥ó" ¶ñ¤W¤F
¦^ÀY¨Ó¬Ý§Aªºµ{¦¡¡A¦pªG§A·í«eµe­±¦b"¤u§@ªí2"¡A¨t²Î·|À°§A§â¤÷ª«¥ó¶ñ¦n¦p¤U
Sheets("¤u§@ªí1").Range(Sheets("¤u§@ªí2").Cells(i + 2, 2), Sheets("¤u§@ªí2").Cells(i + 2, 6)).Copy

³o¤U§Aª¾¹D°ÝÃD¦b­þ¤F§a!? §A·QÅý¹q¸£¦b¤u§@ªí1§ä¤u§@ªí2ªºÀx¦s®æ¡A·íµM§ä¤£¨ì!

¼g¦¨¤U­±´N¨S°ÝÃD¤F

a.Range(a.Cells(i + 2, 2), a.Cells(i + 2, 6)).Copy
©ÎªÌ
Sheets("¤u§@ªí1").Range(Sheets("¤u§@ªí1").Cells(i + 2, 2), Sheets("¤u§@ªí1").Cells(i + 2, 6)).Copy


ı±o«Üªø¶Ü? §A¥i¥H¥Î­ì¥»ªº¤è¦¡ a.Select ¤Á´«·í«e¤u§@ªí¡A©ÎªÌ§AÀ³¸Ó­n¾Ç¾Ç¥Î With(¥¿±`VBA¼ô¤âªº¥Îªk)
With Sheets("¤u§@ªí1")
    .Range(.Cells(i + 2, 2), .Cells(i + 2, 6)).Copy
End With
µ{¦¡¬O¨Ì»Ý¨D¼gªº¡A»Ý¨Dªí¹F¤£²M·¡
©ÎªÌ¨S¦³¤W¶Çªþ¥ó¡A·R²ö¯à§U

TOP

¥»©«³Ì«á¥Ñ n7822123 ©ó 2020-6-20 14:10 ½s¿è

¦^´_ 1# mash071896


¥ÎWith µ²¦X§Aªº¨ä¥Lµ{¦¡¥i¥H²¤°µÂ²¤Æ ¦p¤U

Sub test2()
Sheets("¤u§@ªí2").Activate   '³]·í«e¤u§@ªí¬° ¤u§@ªí2
For i = 0 To 2
  With Sheets("¤u§@ªí1")
      .Range(.Cells(i + 2, 2), .Cells(i + 2, 6)).Copy                                      ' ¤u§@ªí1 ½Æ»s
      Cells(i * 9 + 2, 2).PasteSpecial xlPasteValues, xlNone, False, True  ' ¤u§@ªí2(³Q¬Ù²¤)  ¶K¤W
  End With
Next
End Sub
µ{¦¡¬O¨Ì»Ý¨D¼gªº¡A»Ý¨Dªí¹F¤£²M·¡
©ÎªÌ¨S¦³¤W¶Çªþ¥ó¡A·R²ö¯à§U

TOP

¦^´_ 3# n7822123

·PÁ¤j¤j ­ì¨Ó¬Ocell³¡¤À¥X¿ù
¾Ç¨ì¤Fwith

TOP

¦^´_ 2# n7822123
·PÁ¸Բӻ¡©ú¤÷¥N »P¤l¥NªºÃö«Y

TOP

        ÀR«ä¦Û¦b : ¤H¥Í¤£¤@©w²y²y¬O¦n²y¡A¦ý¬O¦³¾ú½mªº±j¥´ªÌ¡AÀH®É³£¥i¥H´§´Î¡C
ªð¦^¦Cªí ¤W¤@¥DÃD