Vidakuzi vinatusaidia kutoa huduma zetu. Kwa kutumia huduma zetu, unakubaliana na matumizi yetu ya kuki.
Kidokezo: Lugha zingine ni Google-Ilitafsiriwa. Unaweza kutembelea English toleo la kiungo hiki.
Ingia
x
or
x
x
Daftari
x

or

Jinsi ya kurudia safu kulingana na thamani ya seli katika safu?

Kwa mfano, nina data nyingi ambazo zina orodha ya nambari katika safu ya D, na sasa, nataka kurudia safu nzima kwa mara kadhaa kulingana na thamani za nambari kwenye safu ya D ili kupata matokeo yafuatayo. Ningewezaje kunakili safu mara nyingi kulingana na maadili ya seli katika Excel?

doc duplicate safu kwa kiini 1

Duplicate safu mara nyingi kulingana na maadili ya seli na VBA code


Mshale wa bluu wa kulia Duplicate safu mara nyingi kulingana na maadili ya seli na VBA code

Ili kuchapisha na kurudia safu nzima mara nyingi kulingana na maadili ya kiini, kanuni ya VBA ifuatazo inaweza kukusaidia, tafadhali fanya kama hii:

1. Weka chini ALT + F11 funguo za kufungua Microsoft Visual Msingi kwa Maombi dirisha.

2. Bonyeza Ingiza > Modules, na ushirike nambari ifuatayo katika Modules Dirisha.

Nambari ya VBA: Duplicate safu mara nyingi kulingana na thamani ya seli:

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. Kisha waandishi wa habari F5 ufunguo wa kuendesha msimbo huu, safu nzima imechukuliwa mara nyingi kulingana na thamani ya seli katika safu ya D kama unahitaji.

Kumbuka: Katika kanuni iliyo hapo juu, barua A inaonyesha safu ya kuanza ya data yako, na barua D ni barua ya safu ambayo unataka kurudia safu zilizo msingi. Tafadhali ubadilisha kwa mahitaji yako.



Zilizopendekeza Vifaa vya Uzalishaji

Tabia ya Ofisi

nyota ya dhahabu1 Kuleta tabo za Handy kwa Excel na programu nyingine za Ofisi, kama Chrome, Firefox na Internet Explorer mpya.

Kutools kwa Excel

nyota ya dhahabu1 Kushangaza! Ongeza uzalishaji wako katika dakika ya 5. Hauna haja ujuzi wowote maalum, ila saa mbili kila siku!

nyota ya dhahabu1 Features mpya ya 300 kwa Excel, Fanya Excel Rahisi Rahisi na Nguvu:

  • Unganisha Kiini / Rangi / nguzo bila kupoteza Data.
  • Kuchanganya na Kuunganisha Karatasi nyingi na Vitabu vya Kazi.
  • Linganisha Mipangilio, Nakili Ranges nyingi, Badilisha Nakala hadi Tarehe, Kitengo na Ubadilishaji wa Fedha.
  • Hesabu na Rangi, Vipindi vya Paging, Chagua cha Juu na cha Filter Super,
  • Chagua zaidi / Ingiza / Futa / Nakala / Fomu / Kiungo / Maoni / Vitabu vya Kazi / Vifungu vya Kazi ...

Screen shot ya Kutools kwa 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