Cookieak gure zerbitzuak hornitzen laguntzen digute. Gure zerbitzuak erabiltzerakoan, cookieen erabilera onartzen duzu.
Aholkua: beste hizkuntza Google-k itzulitako dira. Bisitatu dezakezu English estekaren bertsioa.
Saioa hasi
x
or
x
x
Eman izena
x

or

Zelulak zutabe batean oinarritutako errenkadak nola bikoiztu?

Adibidez, zutabeetako D zenbakiak dituen datu sorta bat dut, eta orain, errenkada osoak bikoiztu nahi ditut zutabean D balio numerikoen arabera, hurrengo emaitza lortzeko. Nola aldatu ditzaket errenkadak hainbat aldiz zelulen balioetan oinarrituta?

doc bikoiztu errenkadak zelula 1 bidez

Errenkada bikoiztu VBA kode batekin zelula-balioetan oinarrituta


arrow urdina eskuineko burbuila Errenkada bikoiztu VBA kode batekin zelula-balioetan oinarrituta

Hainbat gelaxka kopiatzeko eta bikoizteko gelaxka-balioetan oinarrituta, hurrengo VBA kodea lagungarri izango zaizu, honela egin hau:

1. Eutsi behera ALT + F11 teklak irekitzeko Microsoft Visual Basic aplikazioak leihoa.

2. Egin klik Txertatu > Moduluak, eta ondorengo kodea itsatsi ezazu Moduluak Leiho.

VBA kodea: bikoiztu errenkak hainbat aldiz zelula-balioan oinarrituta:

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. Ondoren, sakatu F5 Kode hau exekutatzeko gakoa, errenkada osoak bikoiztu egin dira hainbat aldiz, zutabe-gelaxkaren balioaren arabera, D behar bezala.

Ohar: Goiko kodean, letra A Zure datuen barrutiko hasierako zutabea adierazten du, eta letra D errenkada bikoiztu nahi dituzun zutabeen letra da. Aldatu zure beharra.



Gomendatutako produktibitate tresnak

Bulegoko fitxa

urrezko izarra1 Lortu erabilgarriak fitxak Excelera eta beste Office softwarearentzako, Chrome bezalakoak, Firefox eta Internet Explorer berriak.

Kutools for Excel

urrezko izarra1 Harrigarria! Handitu zure produktibitatea 5 minutu barru. Ez duzu gaitasun berezirik behar, bi ordu egunero gorde!

urrezko izarra1 300 Ezaugarri berriak Excel-era, Egin Excel oso erraza eta indartsua:

  • Batu gelaxkak / errenkadak / zutabeak datuak galdu gabe.
  • Konbinatu eta finkatzea orri anitzeko lanak.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit eta Currency Conversion.
  • Koloreak arabera, Orrialdeak guztira, Sortu aurreratua eta Super iragazkia,
  • Gehiago Hautatu / Txertatu / Ezabatu / Testua / Formatua / Esteka / Iruzkina / Lan-liburuak / Fitxen tresnak ...

Kutools-en Excel-eko pantaila-argazkia

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