How to repeat steps once first set of rows are filled in

geordie_ben

Board Regular
Joined
Jul 27, 2009
Messages
122
I'm populating some files to import into another system

Here's the code so far. This is part of a bigger piece of coding

Code:
If Sheets("Nom Prod Dim Tag Legs").Range("A" & Rows.Count).End(xlUp).Row > 2 Then _       Sheets("Nom Prod Dim Tag Legs").Range("A3:A" & Sheets("Nom Prod Dim Tag Legs").Range("A" & Rows.Count).End(xlUp).Row).ClearContents


    With Sheets("Nom Prod Dim Tags")
        .Range(.Range("E2"), .Range("E2").End(xlDown)).Copy Sheets("Nom Prod Dim Tag Legs").Range("A2")
    End With


    With Sheets("Nom Prod Dim Tag Legs")
        .Range("B2").AutoFill Destination:=.Range("B2:B" & .Range("A" & Rows.Count).End(xlUp).Row)
    End With


    With Sheets("Nom Prod Dim Tag Legs")
        .Range("C2").AutoFill Destination:=.Range("C2:C" & .Range("A" & Rows.Count).End(xlUp).Row)
    End With
    
    With Sheets("Nom Prod Dim Tag Legs")
        .Range("D2").AutoFill Destination:=.Range("D2:D" & .Range("A" & Rows.Count).End(xlUp).Row)
    End With

At the moment the cell content of C2 is "Sales"

Once the above has ran, I then need to set he next empty cell in C to "Purchases" and have the code repeat so that I end up with say 10 lines of Sales, and then 10 lines of Purchases. 10 is an example

If it makes it easier I could add the words Sales and Purchases into two separate cells on an different sheet
 
Last edited:

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Watch MrExcel Video

Forum statistics

Threads
1,123,504
Messages
5,602,044
Members
414,497
Latest member
guitarmanz

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
Top