Delete specific number of rows from WORD tablePrevent user from deleting certain rows based on contents of a cell in that rowDeleting last row in table of protected sheetVBA Word macro - inserting table rows at end of table creates infinite loopDelete Table Row Interop WordDeleting or keeping multiple rows by a specific word contentImport rows from table in Word document to another Word documentWord VBA deleting added rows from tableMacro to Count Rows in One Table and Add that # Rows in Second TableInsert Row button with hidden rows at bottom of form: when added then deleted, new rows appear at bottomWord Copying, Pasting and Deleting Columns with VBA

I'm attempting to understand my 401k match and how much I need to contribute to maximize the match

logo selection for poster presentation

Does this website provide consistent translation into Wookiee?

Two (probably) equal real numbers which are not proved to be equal?

Crime rates in a post-scarcity economy

What are my options legally if NYC company is not paying salary?

Why is the episode called "The Last of the Starks"?

What is the oldest instrument ever?

Are wands in any sort of book going to be too much like Harry Potter?

How to append code verbatim to .bashrc?

What's an appropriate age to involve kids in life changing decisions?

My parents are Afghan

Capturing the entire webpage with WebExecute's CaptureImage

Can radiation block all wireless communications?

Is the tensor product (of vector spaces) commutative?

When was it publicly revealed that a KH-11 spy satellite took pictures of the first Shuttle flight?

History: Per Leviticus 19:27 would the apostles have had corner locks ala Hassidim today?

My Sixteen Friendly Students

Steganography in Latex

Names of the Six Tastes

As a small race with a heavy weapon, does enlage remove the disadvantage?

Why did Ham the Chimp push levers?

Expl3 and recent xparse on overleaf: No expl3 loader detected

What happens when the drag force exceeds the weight of an object falling into earth?



Delete specific number of rows from WORD table


Prevent user from deleting certain rows based on contents of a cell in that rowDeleting last row in table of protected sheetVBA Word macro - inserting table rows at end of table creates infinite loopDelete Table Row Interop WordDeleting or keeping multiple rows by a specific word contentImport rows from table in Word document to another Word documentWord VBA deleting added rows from tableMacro to Count Rows in One Table and Add that # Rows in Second TableInsert Row button with hidden rows at bottom of form: when added then deleted, new rows appear at bottomWord Copying, Pasting and Deleting Columns with VBA






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm creating a user form for users to insert/paste data in a table in WORD. I've written code for the user to insert specified number of rows into the table, in addition, each row is sequentially numbered when added. I've tried to reverse code to delete specified number of rows unsuccessfully.



The code I've written code to provide the user with the option to delete a specified number of rows is not working as I've planned. Message received: Wrong number of arguments or invalid property assignment.



Sub DeleteRowsFromTable()
Dim nNumber as Long

Active.document.Tables(2).Select
If Selection.Information(wdWithInTable) = True Then
nNumber = InputBox("Input the number of rows you want to delete:", "Delete rows from the selection")
Selection.Tables(2).Rows.Last.Delete NumRows:=nNumber

end if

end sub


Expected result for user to choose quantity of rows to from bottom of table(2), regardless if row is empty or not.










share|improve this question






























    0















    I'm creating a user form for users to insert/paste data in a table in WORD. I've written code for the user to insert specified number of rows into the table, in addition, each row is sequentially numbered when added. I've tried to reverse code to delete specified number of rows unsuccessfully.



    The code I've written code to provide the user with the option to delete a specified number of rows is not working as I've planned. Message received: Wrong number of arguments or invalid property assignment.



    Sub DeleteRowsFromTable()
    Dim nNumber as Long

    Active.document.Tables(2).Select
    If Selection.Information(wdWithInTable) = True Then
    nNumber = InputBox("Input the number of rows you want to delete:", "Delete rows from the selection")
    Selection.Tables(2).Rows.Last.Delete NumRows:=nNumber

    end if

    end sub


    Expected result for user to choose quantity of rows to from bottom of table(2), regardless if row is empty or not.










    share|improve this question


























      0












      0








      0








      I'm creating a user form for users to insert/paste data in a table in WORD. I've written code for the user to insert specified number of rows into the table, in addition, each row is sequentially numbered when added. I've tried to reverse code to delete specified number of rows unsuccessfully.



      The code I've written code to provide the user with the option to delete a specified number of rows is not working as I've planned. Message received: Wrong number of arguments or invalid property assignment.



      Sub DeleteRowsFromTable()
      Dim nNumber as Long

      Active.document.Tables(2).Select
      If Selection.Information(wdWithInTable) = True Then
      nNumber = InputBox("Input the number of rows you want to delete:", "Delete rows from the selection")
      Selection.Tables(2).Rows.Last.Delete NumRows:=nNumber

      end if

      end sub


      Expected result for user to choose quantity of rows to from bottom of table(2), regardless if row is empty or not.










      share|improve this question
















      I'm creating a user form for users to insert/paste data in a table in WORD. I've written code for the user to insert specified number of rows into the table, in addition, each row is sequentially numbered when added. I've tried to reverse code to delete specified number of rows unsuccessfully.



      The code I've written code to provide the user with the option to delete a specified number of rows is not working as I've planned. Message received: Wrong number of arguments or invalid property assignment.



      Sub DeleteRowsFromTable()
      Dim nNumber as Long

      Active.document.Tables(2).Select
      If Selection.Information(wdWithInTable) = True Then
      nNumber = InputBox("Input the number of rows you want to delete:", "Delete rows from the selection")
      Selection.Tables(2).Rows.Last.Delete NumRows:=nNumber

      end if

      end sub


      Expected result for user to choose quantity of rows to from bottom of table(2), regardless if row is empty or not.







      vba ms-word






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 19:13









      Cindy Meister

      16.3k102538




      16.3k102538










      asked Mar 23 at 7:28









      Rey TainoRey Taino

      73212




      73212






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Try:



          Sub DeleteRowsFromTable()
          Application.ScreenUpdating = False
          Dim n As Long, r As Long
          With ActiveDocument.Tables(2)
          On Error GoTo ErrExit
          n = InputBox("Input the number of rows you want to delete:", "Delete rows from the table")
          For r = .Rows.Count To 1 Step -1
          If n = 0 Then Exit For
          If r < 7 Then Exit For
          .Rows(r).Delete
          n = n - 1
          Next
          End With
          ErrExit:
          Application.ScreenUpdating = True
          End Sub





          share|improve this answer

























          • macropod - thank you. code works with no errors. I have one more question: How can I prevent the user from deleting the first 6 rows; 1st row is the header row, and the next five I need to have displayed at all times. Again, thank you for your help on this.

            – Rey Taino
            Mar 24 at 12:27











          • If you have something new to ask, ask a new question - don't extend what you want in a comment, @ReyTaino

            – Cindy Meister
            Mar 24 at 19:12











          • @ReyTaino You should specify all your requirements in the question; not roll them out piecemeal. This is the second time you've changed your requirements via a comment. Answer updated.

            – macropod
            Mar 25 at 1:57











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311609%2fdelete-specific-number-of-rows-from-word-table%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Try:



          Sub DeleteRowsFromTable()
          Application.ScreenUpdating = False
          Dim n As Long, r As Long
          With ActiveDocument.Tables(2)
          On Error GoTo ErrExit
          n = InputBox("Input the number of rows you want to delete:", "Delete rows from the table")
          For r = .Rows.Count To 1 Step -1
          If n = 0 Then Exit For
          If r < 7 Then Exit For
          .Rows(r).Delete
          n = n - 1
          Next
          End With
          ErrExit:
          Application.ScreenUpdating = True
          End Sub





          share|improve this answer

























          • macropod - thank you. code works with no errors. I have one more question: How can I prevent the user from deleting the first 6 rows; 1st row is the header row, and the next five I need to have displayed at all times. Again, thank you for your help on this.

            – Rey Taino
            Mar 24 at 12:27











          • If you have something new to ask, ask a new question - don't extend what you want in a comment, @ReyTaino

            – Cindy Meister
            Mar 24 at 19:12











          • @ReyTaino You should specify all your requirements in the question; not roll them out piecemeal. This is the second time you've changed your requirements via a comment. Answer updated.

            – macropod
            Mar 25 at 1:57















          1














          Try:



          Sub DeleteRowsFromTable()
          Application.ScreenUpdating = False
          Dim n As Long, r As Long
          With ActiveDocument.Tables(2)
          On Error GoTo ErrExit
          n = InputBox("Input the number of rows you want to delete:", "Delete rows from the table")
          For r = .Rows.Count To 1 Step -1
          If n = 0 Then Exit For
          If r < 7 Then Exit For
          .Rows(r).Delete
          n = n - 1
          Next
          End With
          ErrExit:
          Application.ScreenUpdating = True
          End Sub





          share|improve this answer

























          • macropod - thank you. code works with no errors. I have one more question: How can I prevent the user from deleting the first 6 rows; 1st row is the header row, and the next five I need to have displayed at all times. Again, thank you for your help on this.

            – Rey Taino
            Mar 24 at 12:27











          • If you have something new to ask, ask a new question - don't extend what you want in a comment, @ReyTaino

            – Cindy Meister
            Mar 24 at 19:12











          • @ReyTaino You should specify all your requirements in the question; not roll them out piecemeal. This is the second time you've changed your requirements via a comment. Answer updated.

            – macropod
            Mar 25 at 1:57













          1












          1








          1







          Try:



          Sub DeleteRowsFromTable()
          Application.ScreenUpdating = False
          Dim n As Long, r As Long
          With ActiveDocument.Tables(2)
          On Error GoTo ErrExit
          n = InputBox("Input the number of rows you want to delete:", "Delete rows from the table")
          For r = .Rows.Count To 1 Step -1
          If n = 0 Then Exit For
          If r < 7 Then Exit For
          .Rows(r).Delete
          n = n - 1
          Next
          End With
          ErrExit:
          Application.ScreenUpdating = True
          End Sub





          share|improve this answer















          Try:



          Sub DeleteRowsFromTable()
          Application.ScreenUpdating = False
          Dim n As Long, r As Long
          With ActiveDocument.Tables(2)
          On Error GoTo ErrExit
          n = InputBox("Input the number of rows you want to delete:", "Delete rows from the table")
          For r = .Rows.Count To 1 Step -1
          If n = 0 Then Exit For
          If r < 7 Then Exit For
          .Rows(r).Delete
          n = n - 1
          Next
          End With
          ErrExit:
          Application.ScreenUpdating = True
          End Sub






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 25 at 1:55

























          answered Mar 23 at 8:37









          macropodmacropod

          3,3322312




          3,3322312












          • macropod - thank you. code works with no errors. I have one more question: How can I prevent the user from deleting the first 6 rows; 1st row is the header row, and the next five I need to have displayed at all times. Again, thank you for your help on this.

            – Rey Taino
            Mar 24 at 12:27











          • If you have something new to ask, ask a new question - don't extend what you want in a comment, @ReyTaino

            – Cindy Meister
            Mar 24 at 19:12











          • @ReyTaino You should specify all your requirements in the question; not roll them out piecemeal. This is the second time you've changed your requirements via a comment. Answer updated.

            – macropod
            Mar 25 at 1:57

















          • macropod - thank you. code works with no errors. I have one more question: How can I prevent the user from deleting the first 6 rows; 1st row is the header row, and the next five I need to have displayed at all times. Again, thank you for your help on this.

            – Rey Taino
            Mar 24 at 12:27











          • If you have something new to ask, ask a new question - don't extend what you want in a comment, @ReyTaino

            – Cindy Meister
            Mar 24 at 19:12











          • @ReyTaino You should specify all your requirements in the question; not roll them out piecemeal. This is the second time you've changed your requirements via a comment. Answer updated.

            – macropod
            Mar 25 at 1:57
















          macropod - thank you. code works with no errors. I have one more question: How can I prevent the user from deleting the first 6 rows; 1st row is the header row, and the next five I need to have displayed at all times. Again, thank you for your help on this.

          – Rey Taino
          Mar 24 at 12:27





          macropod - thank you. code works with no errors. I have one more question: How can I prevent the user from deleting the first 6 rows; 1st row is the header row, and the next five I need to have displayed at all times. Again, thank you for your help on this.

          – Rey Taino
          Mar 24 at 12:27













          If you have something new to ask, ask a new question - don't extend what you want in a comment, @ReyTaino

          – Cindy Meister
          Mar 24 at 19:12





          If you have something new to ask, ask a new question - don't extend what you want in a comment, @ReyTaino

          – Cindy Meister
          Mar 24 at 19:12













          @ReyTaino You should specify all your requirements in the question; not roll them out piecemeal. This is the second time you've changed your requirements via a comment. Answer updated.

          – macropod
          Mar 25 at 1:57





          @ReyTaino You should specify all your requirements in the question; not roll them out piecemeal. This is the second time you've changed your requirements via a comment. Answer updated.

          – macropod
          Mar 25 at 1:57



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311609%2fdelete-specific-number-of-rows-from-word-table%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현