Fill down formulas and Do Until "No more data"

AliB

New Member
Joined
Dec 11, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi

I am new to Mr Excel, returning to VBA after many years' break (I've been using power query for most of my solutions) and am hoping that some of you clever people will be able to solve my conundrum.

I have a spreadsheet that picks up data from another sheet from the same workbook, does a few lookups and presents the data in a different format.

Each line in the extract below represents an equipment installation that needs to be completed, and the Qty in column G shows how many instances of that installation will need to take place. If only 1 installation, then nothing needs to happen but if there are more than one, we need to insert additional rows and filldown the formulas for the whole row, and then overwrite the values in column G to 1. Then move on to the next one.

The formulas in columns D, E and F are based on the number in column C. So, for example, rows 33 to 35 need to say 22. Formulas from column G onwards are then based on the combined values of C, D, E and F.

1702287997800.png


The numbers in Column C are currently manually input until we get the result "No more data" (see below). I'm wondering if there is another macro that could be built in to automate this process too.

1702288298624.png



I have managed to find a macro that will insert the extra rows but I am having trouble with filling down the formulas. For the life of me I cannot work out how to tell it to stop when the result in column D says "No more data". The last thing I tried ended up in a never-ending loop!

This is all I have so far:


1702288646105.png




Any help you can give me would be very much appreciated.

Yours hopefully,

AliB
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about doing it with power query?:

With this table as input:
FillDownFormulas.xlsx
BCDEF
1ItemHeadingEquipmentLevelQty
21Heading01ADP0111
32Heading02LBP0121
43Heading03UIP0113
54Heading04UMS0122
65Heading05UPM11
Hoja1


And this code:
Power Query:
let
    Origen = Excel.CurrentWorkbook(){[Name="Tabla1"]}[Content],
    Typed = Table.TransformColumnTypes(Origen,{{"Item", Int64.Type}, {"Heading", type text}, {"Equipment", type text}, {"Level", Int64.Type}, {"Qty", Int64.Type}}),
    Repeated = Table.TransformColumns(Typed, {"Qty", each List.Numbers(_,_,0), type list}),
    Expanded = Table.ExpandListColumn(Repeated, "Qty"),
    ColumnsRemoved = Table.RemoveColumns(Expanded,{"Qty"}),
    CustomColumn = Table.AddColumn(ColumnsRemoved, "Qty", each 1)
in
    CustomColumn

You get:
FillDownFormulas.xlsx
BCDEF
1ItemHeadingEquipmentLevelQty
21Heading01ADP0111
32Heading02LBP0121
43Heading03UIP0111
53Heading03UIP0111
63Heading03UIP0111
74Heading04UMS0121
84Heading04UMS0121
95Heading05UPM11
Tabla1


You just have to add the formulas of columns I to N
 
Upvote 0
Solution

Forum statistics

Threads
1,224,813
Messages
6,181,114
Members
453,021
Latest member
Justyna P

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