VBA: Insert new row below active cell, copy data in specific cells above the new row.

Ibyb

New Member
Joined
Jul 1, 2022
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi, I am creating a dataset that pulls information from another sheet using vlookup.
Once the data is pulled in, I will be adding new data beneath the top vlookup row in a controlled but specific format, i.e. data validated lists etc.
There are hundreds of vlookup enteries.

So for instance by default there will be 4 rows per group of data and the list could expand to a further 100 rows.
I have opted to use Active X buttons to add new rows using VBA: AcitveCell.Offset(1,0).EntireRow.Insert. This will add a new row below the cell I have selected.
This works really well. A button will be used to copy data down.

The Issue: Once I add the new row, I cannot get specific data to copy and paste into the new row from the row above so that when I use a filter it includes the new row as part of the data. The record macro code always locks to the cell I captured the data from and is always static. It doesn't automatically adapt to when a new row is added.


Example below
Start Position
Row 1: Vlookup information
Row 2: A information
Row 3: B Information
Row 4: Totals

New Position once I have added new rows using activeCell.Offset
Row 1: Vlookup information
Row 2: A Information
Row 3: A information
Row 4: A Information
Row 5: B information
Row 6: B information
Row 7: B information
Row 8: Totals

The new rows will always be added beneath the main row A or B. and I want to copy the information from column "B" and "C" only automatically into the new row below when the button is pressed.

I've struggled to detail what I'm trying to do without revealing too much. Hope you can help :)
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Also use code tags to post all the code you are currently using. Alternately, you could upload a copy of your file which includes your current code to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,485
Members
448,967
Latest member
visheshkotha

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