Results 1 to 11 of 11

VBA: repeat a formula a number of times

Threaded View

  1. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: VBA: repeat a formula a number of times

    The "Data" array is a two dimensional array. The column number indices for Data are 1 and 2, and not the same column numbers as on the worksheet e.g. 15 and 16.

    Also, put this in a standard code module e.g. Module1 and not the worksheet's code module.

    Sub Repeat_Data()
        
        Dim Data
        Dim i As Long, NextRow As Long
      
        Data = Range("O1", Range("P" & Rows.count).End(xlUp)).Value
        NextRow = 2
        
        Application.ScreenUpdating = False
        For i = 1 To UBound(Data, 1)
            Cells(NextRow, "J").Resize(Data(i, 1)).Value = Data(i, 2)
            NextRow = NextRow + Data(i, 1)
        Next i
        Application.ScreenUpdating = True
        
    End Sub
    Last edited by AlphaFrog; 02-24-2013 at 10:05 AM.

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