Adding pre-populated rows under specific cells

robotrobert

New Member
Joined
May 20, 2020
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Hi friends,
I recently started using Excel for a large worksheet and am hoping someone could help me with the following:
In my table in column Y, there will be 2 numbers alternating between 1 and 2 (Y2 is 1, Y2 is 2, Y3 is 1, and so on...)
In column X the images are represented (X2 is 'image 1', X3 is 'image 2', X4 is 'image 1', and so on...)
I need assistance to create a macro that will look at column Y, and underneath any cell that contains 2, to add X rows (I'm currently leaning towards 6 additional rows but may need 7 or 8) that contain specific text in cells in columns X and Y (i.e. a new row is created and contains 'image 3' in X4 and '3' in Y4, etc.)
I added a screenshot to show how it currently looks and what I hope to achieve. Any help is greatly appreciated!
Thank you!
 

Attachments

  • Excel Question.png
    Excel Question.png
    30.5 KB · Views: 5

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi and welcome to MrExcel.

How about:

VBA Code:
Sub AddingCells()
  Dim a As Range
  For Each a In Range("X2", Range("X" & Rows.Count).End(3)).SpecialCells(xlCellTypeConstants).Areas
    a.Resize(1, 2).Offset(1).AutoFill a.Resize(6, 2).Offset(1), xlFillDefault
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,530
Members
448,969
Latest member
mirek8991

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