+ Reply to Thread
Results 1 to 2 of 2

how do I repeat rows of the same text in a worksheet?

Hybrid View

  1. #1
    Registered User
    Join Date
    11-04-2006
    Posts
    2

    how do I repeat rows of the same text in a worksheet?

    Colleagues,

    I would like to get some help on how to create macros that will fill unknown number of rows of an excel sheet with repeated text. The excel sheet is coming from a different application, so the size could change from time to time. It could be 30 rows one time and 60 rows another time and 12 rows another time. What I need to do is that, any time I get the excel file, I want row1 to be populated with the text "Old Orders", Row2 to be populated with the text "New Orders" and Row3 to be populated with the text "Impending Orders". This trend should be repeated in Rows 4, 5 and 6, then in Rows 7, 8 and 9 until the end of the file. Please I need some help in doing this ASAP.

    Thanks.

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Try this ...

    Sub Macro1()
    Dim ws As Worksheet
    
    'assume data starts in column A and you want to
    'write text to column H
    
        Set ws = ThisWorkbook.Sheets("your sheet name here")
        ws.Select
        
        lastRow = Cells(ws.Rows.Count, 1).End(xlUp).Row
        
        For i = 1 To lastRow Step 3
            Range("H" & i) = "Old Orders"
            Range("H" & i + 1) = "New Orders"
            Range("H" & i + 2) = "Impending Orders"
        Next i
        
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1