Bonbon ede nou delivre sèvis nou yo. Lè l sèvi avèk sèvis nou yo, ou dakò pou nou sèvi ak bonbon.
Ide: Lòt lang yo se Google-tradui. Ou ka vizite a English vèsyon nan lyen sa a.
Ouvri yon sesyon
x
or
x
x
enskri
x

or

Ki jan yo kopi ranje ki baze sou valè selil nan yon kolòn?

Pou egzanp, mwen gen yon seri de done ki gen yon lis nimewo nan kolòn D, e kounye a, mwen vle kopi ranje yo tout antye yon kantite fwa ki baze sou valè yo nimerik nan kolòn D yo ka resevwa rezilta sa a. Kouman mwen ka kopye ranje yo plizyè fwa ki baze sou valè selil yo nan Excel?

doc ranje ranje pa selil 1

Diplin ranje plizyè fwa ki baze sou valè selil ak kòd VBA


flèch ble jarèt dwat Diplin ranje plizyè fwa ki baze sou valè selil ak kòd VBA

Pou kopye ak kopi ranje yo tout antye plizyè fwa ki baze sou valè selil yo, kòd VBA sa yo ka ede ou, tanpri fè tankou sa a:

1. Kenbe desann la ALT + F11 kle yo louvri a Microsoft Visual Basic pou aplikasyon pou fenèt.

2. Klike sou Antre > Modil, epi kole kòd sa a nan la Modil Fenèt.

VBA Kòd: Diplikasyon ranje plizyè fwa ki baze sou valè selil:

Sub CopyData()
'Updateby Extendoffice 20160922
    Dim xRow As Long
    Dim VInSertNum As Variant
    xRow = 1
    Application.ScreenUpdating = False
    Do While (Cells(xRow, "A") <> "")
        VInSertNum = Cells(xRow, "D")
        If ((VInSertNum > 1) And IsNumeric(VInSertNum)) Then
           Range(Cells(xRow, "A"), Cells(xRow, "D")).Copy
           Range(Cells(xRow + 1, "A"), Cells(xRow + VInSertNum - 1, "D")).Select
           Selection.Insert Shift:=xlDown
           xRow = xRow + VInSertNum - 1
        End If
        xRow = xRow + 1
    Loop
    Application.ScreenUpdating = False
End Sub

3. Lè sa a, peze F5 kle nan kouri kòd sa a, ranje yo tout yo te double fwa miltip ki baze sou valè a selil nan kolòn D menm jan ou bezwen.

nòt: Nan kòd ki anwo a, lèt la A endike kolòn nan kòmanse nan ranje done ou a, ak lèt ​​la D se lèt la kolòn ke ou vle kopi ranje yo ki baze sou. Tanpri chanje yo nan bezwen ou.



Rekòmande Zouti Productivity

Biwo Tab

lò star1 Pote onglè sou lamen pou Excel ak lòt biwo lojisyèl, jis tankou Chrome, Firefox ak nouvo Internet Explorer.

Kutools pou Excel

lò star1 Etonan! Ogmante pwodiktivite ou nan minit 5. Pa bezwen okenn ladrès espesyal, sove de zè de tan chak jou!

lò star1 300 karakteristik nouvo pou Excel, fè Excel anpil fasil ak pwisan:

  • Rantre selilè / ranje / Kolòn san yo pa pèdi done.
  • Konbine ak Konsolide Pliye Plizyè ak Manyèl.
  • Konpare Range, Kopi plizyè chif, Konvèti tèks nan dat, inite ak konvèsyon lajan.
  • Konte pa Koulè, Paging subtotals, Avanse Triye ak Super Filter,
  • Plis Chwazi / Insert / Efase / Tèks / Fòma / Link / Kòmantè / Workbooks / Worksheets Zouti ...

Piki ekran nan Kutools pou Excel

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    KAS · 1 months ago
    Is there a way to update the module to only duplicate new data? I'm working on an ongoing document and do not want the code to duplicate data that has been previously duplicated.
  • To post as a guest, your comment is unpublished.
    Gerardo Enrique Heras Araujo · 2 months ago
    hi, for me is no working, I want to remove letters and number duplicate is possible?
  • To post as a guest, your comment is unpublished.
    Naomi · 2 months ago
    This script seems to be exactly what I need, however, when I run it I am getting an error on the line Selection.Insert Shift:=x1Down

    Any suggestions on how I fix this?
  • To post as a guest, your comment is unpublished.
    Manuel F · 2 months ago
    Thanks! it has been a great solution for all my troubles!
  • To post as a guest, your comment is unpublished.
    Leah · 3 months ago
    Hello, this worked great. However, I have a report with 1000 entries and the code stopped duplicating around entry 480. Is there something that I can add so that it completes the action on the entire report?
    • To post as a guest, your comment is unpublished.
      skyyang · 3 months ago
      Hello, Leah,
      I have tested the code in 2000 rows, and it works well.
      Could you send your worksheet to me for testing the code?
      My email address is skyyang@extendoffice.com
      Look forward to your reply!
      • To post as a guest, your comment is unpublished.
        Leah · 3 months ago
        Hello! I got it to work. It was an error on my side, the report had a few blank rows that were hidden that were causing the script to stop looping. It worked for my report with 8,000 rows! Thank youQ