Vpiši se  \/ 
x
or
x
Registracija  \/ 
x

or

Kako samodejno vstaviti prazno novo vrstico z gumbom za ukaz v Excelu?

V mnogih primerih boste morda morali na določen položaj delovnega lista vstaviti novo prazno vrstico. V tem članku vam bomo pokazali, kako samodejno vstavite novo vrstico s klikom na ukazni gumb v Excelu.

Z ukaznim gumbom samodejno vstavite prazno novo vrstico


Z ukaznim gumbom samodejno vstavite prazno novo vrstico

S klikom na ukazni gumb lahko zaženete naslednjo kodo VBA in vstavite prazno novo vrstico. Naredite naslednje.

1. Najprej morate vstaviti ukazni gumb. Kliknite Razvojni > Vstavi > Ukazni gumb (nadzor ActiveX). Oglejte si posnetek zaslona:

2. Nato na delovni list narišite ukazni gumb, ki ga želite dodati nove vrstice, z desno miškino tipko kliknite ukazni gumb in kliknite Nepremičnine v meniju z desnim klikom.

3. V Ljubljani Nepremičnine v pogovorno okno vnesite prikazano besedilo ukaznega gumba v napis polje pod Kategorizirani in nato zaprite pogovorno okno.

Vidite lahko, da se prikazano besedilo ukaznega gumba spremeni, kot je prikazano spodaj.

4. Znova z desno tipko miške kliknite ukazni gumb in nato kliknite Ogled kode v meniju z desnim klikom.

5. Nato Microsoft Visual Basic za aplikacije okno, zamenjajte izvirno kodo s spodnjo kodo VBA v Koda okno.

Koda VBA: z ukaznim gumbom samodejno vstavi prazno novo vrstico

Private Sub CommandButton1_Click()
    Dim rowNum As Integer
    On Error Resume Next
    rowNum = Application.InputBox(Prompt:="Enter Row Number where you want to add a row:", _
                                    Title:="Kutools for excel", Type:=1)
    Rows(rowNum & ":" & rowNum).Insert Shift:=xlDown
End Sub

Opombe: V kodi je CommanButton1 ime ukaznega gumba, ki ste ga ustvarili.

6. Pritisnite druga + Q tipke hkrati, da zaprete tipko Microsoft Visual Basic za aplikacije okno. In izklopite Način oblikovanja pod Razvojni tab.

7. Kliknite vstavljeni ukazni gumb in a Kutools za Excel odpre se pogovorno okno. Vnesite določeno številko vrstice, kamor želite dodati prazno novo vrstico, in nato kliknite OK . Oglejte si posnetek zaslona:

Nato se prazna nova vrstica vstavi na določen položaj vašega delovnega lista, kot je prikazano spodaj. In ohrani oblikovanje celice zgoraj navedene celice.


Sorodni članki:


Najboljša orodja za pisarniško produktivnost

Kutools za Excel rešuje večino vaših težav in poveča produktivnost za 80%

  • Ponovna uporaba: Hitro vstavite zapletene formule, grafikoni in vse, kar ste že uporabljali; Šifriraj celice z geslom; Ustvari poštni seznam in pošiljanje e-pošte ...
  • Vrstica Super Formula (enostavno urejanje več vrstic besedila in formule); Bralna postavitev (enostavno branje in urejanje velikega števila celic); Prilepite v filtrirani obseg...
  • Združi celice / vrstice / stolpce brez izgube podatkov; Vsebina razdeljenih celic; Združi podvojene vrstice / stolpce... prepreči podvojene celice; Primerjaj obsege...
  • Izberite Duplicate ali Unique Vrstice; Izberite prazne vrstice (vse celice so prazne); Super Find in Fuzzy Find v mnogih delovnih zvezkih; Naključna izbira ...
  • Natančna kopija Več celic brez spreminjanja sklica formule; Samodejno ustvarjanje referenc na več listov; Vstavi oznake, Potrditvena polja in še več ...
  • Izvleček besedila, Dodaj besedilo, Odstrani po položaju, Odstrani presledek; Ustvari in natisni vmesne seštevke strani Pretvarjanje med vsebino celic in komentarji...
  • Super filter (shranite in uporabite sheme filtrov za druge liste); Napredno razvrščanje glede na mesec / teden / dan, pogostost in drugo; Poseben filter s krepko, ležeče ...
  • Združite delovne zvezke in delovne liste; Spoji tabele na podlagi ključnih stolpcev; Razdelite podatke na več listov; Paketna pretvorba xls, xlsx in PDF...
  • Več kot 300 zmogljivih funkcij. Podpira Office / Excel 2007-2019 in 365. Podpira vse jezike. Preprosta namestitev v vašem podjetju ali organizaciji. Vse funkcije 30-dnevnega brezplačnega preskusa. 60-dnevno jamstvo za vračilo denarja.
zavihek kte 201905

Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50% in vsak dan zmanjša na stotine klikov z miško!
dno pisarniške mize
Say something here...
symbols left.
You are guest
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.
    Kamau Kionga · 5 months ago
    Sub AddNewRow()

    Private Sub CommandButton1_Click()
    ActiveSheet.Unprotect Password:="1234"

    Dim mySheets
    Dim i As Long

    mySheets = Array("Sheet2")

    For i = LBound(mySheets) To UBound(mySheets)
    With Sheets(mySheets(i))
    .Range("B10").EntireRow.Insert Shift:=xlDown
    .Range("B10:H10").Borders.Weight = xlThin
    End With
    Next i

    ActiveSheet.Protect Password:="1234"

    End Sub

    I don't know if this will work for you. It worked quite well for me. I even left unprotected cells that you can input data and the formulas are still active. Took me a whole day to figure it out. replace "1234" with whatever password you feel like, "Sheet2" with the Sheet you are working with and input the range you want.
    The code first unprotects the worksheet, adds row and protects the worksheet.
    kiongakamau@gmail.com
  • To post as a guest, your comment is unpublished.
    goncalo.teixeira992@gmail.com · 1 years ago
    is it possible to create in a different sheet? I really need that
  • To post as a guest, your comment is unpublished.
    arif · 1 years ago
    can possible insert multiple sheet row at one time click by this .
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi,
      The below code can help you solve the problem. Please have a try.

      Private Sub CommandButton1_Click()
      Dim xIntRrow As Integer
      Dim rowNum As Integer
      On Error Resume Next
      rowNum = Application.InputBox(Prompt:="Enter Row Number where you want to add a row:", _
      Title:="Kutools for excel", Type:=1)
      xIntRrow = Application.InputBox(Prompt:="Type in the number of rows you want to insert", _
      Title:="Kutools for excel", Type:=1)
      Rows(rowNum + 1 & ":" & rowNum + 1).EntireRow.Resize(xIntRrow).Insert Shift:=xlShiftDown

      End Sub
  • To post as a guest, your comment is unpublished.
    JW · 1 years ago
    Yes, I played with the script and it worked for me. You just add the row number you want (I chose row 6), but I'll be shocked if it's allowed to be published.

    Private Sub CommandButton1_Click()
    Dim rowNum As Integer
    On Error Resume Next
    Rows(rowNum & "6").Insert Shift:=xlDown
    End Sub
  • To post as a guest, your comment is unpublished.
    Tarl · 1 years ago
    Is there a way to have the new row keep the formatting of the row below instead of the row above?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Tarl,
      Sorry can help solving this problem yet. Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    Simon · 2 years ago
    Is there a way to add an Insert Row button and have the new rows keep the cells merged/formatted as they are in the rest of a table?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Simon,
      Sorry can help solving this problem yet. Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    stiles.michellel@gmail.com · 2 years ago
    I'm having the same issue as Kim - When the sheet is unprotected it adds the row with the correct formatting and correct formulas. Once the sheet is protected it doesn't copy down the formulas. Any thoughts?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Dear Michelle,
      By default, a protected worksheet does not allow to insert blank row.
      Therefore, the VBA code can't work in that case.
  • To post as a guest, your comment is unpublished.
    Kim · 3 years ago
    Hi

    I am using this code but it is not bringing down the formulas from the row before, can you help please.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Kim,

      Please insert a Table with the range you will insert blank rows inside. After that, when inserting new row, the formula will bring down automatically.

      Best Regards, Crystal
      • To post as a guest, your comment is unpublished.
        Robert · 2 years ago
        Can you provide an example? Not following what you're say here. Thanks
        • To post as a guest, your comment is unpublished.
          crystal · 2 years ago
          Hi,
          Please convert your range to a table range in order to bring down the formula automatically when inserting new rows. See screenshot:
  • To post as a guest, your comment is unpublished.
    Lydia · 3 years ago
    Could anyone advise on how can I amend this to automatically add the new row to the bottom of an excel table?
    • To post as a guest, your comment is unpublished.
      Raviv · 3 years ago
      did you find the answer ?