Check if current row is last one, if so add a new row

grabrail

Board Regular
Joined
Sep 6, 2010
Messages
128
Office Version
  1. 365
Platform
  1. Windows
I have a workbook that when a certain field is changed to a specific value a pop up form appears that needs to be filled in, when the form is submitted, the data entered is put into a table on the main worksheet.

There are currently 30 empty rows that can be populated, and up to now this has been more than enough, however over the last few days there have been a few entries that fill up all 30 rows and need more.

Currently my code looks for the next empty row, and then puts the data there using the following code:

VBA Code:
 Worksheets("VI Sheet").Range("A112").Select
        'get next blank cell
            While ActiveCell.Value <> ""
                ActiveCell.Offset(1, 0).Range("A1").Select
            Wend
        'input results

the lines of code after this populate the row with the data.

My question is, how do I add or change the code to check if it has reached the 30th empty row in currently cell A143, if it has reached this row and it is populated, it will add a new row below to paste the data?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
What is in row 144 so that you need to "add a new row below to paste the data"
 
Upvote 0
All the rows where the data is pasted are a laid out table, not a formatted table, just created with outlines

row 144 is the bottom of this table and is just formatted in a solid color to mark the end of the data, below this there is just some text.
table.png
 
Upvote 0
Ive achieved what I need by adding a 0 value in the first cell of the black line, formatted with black text so its not visible, then modified my code to the following

VBA Code:
 While ActiveCell.Value <> ""
                            ActiveCell.Offset(1, 0).Range("A1").Select
                            If ActiveCell.Value = "0" Then
                                ActiveCell.Offset(-1, 0).Range("A1").Select
                                ActiveCell.Offset(1, 0).EntireRow.Insert
                            End If
 
Upvote 0
Solution

Forum statistics

Threads
1,223,705
Messages
6,173,985
Members
452,540
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top