View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
EK EK is offline
external usenet poster
 
Posts: 20
Default Populate Data In Rows

Yes, it works. Except that this code also re-sorted the order of the data in
Col A and B. I would like it sorted Col C by the repeat count and leave Col A
and B intact. The code from Gary"s Student did just that.

For this code, what do I have to change in order to re-populate with a
different definition such as:
A=6 times, B=3 times, C=2 times and D=1 time?

Thanks, EK.




"Rick Rothstein (MVP - VB)" wrote:

I've made a minor modification to my subroutine, so when you follow the
instructions below, make sure you use the code posted in this message.

Go to the worksheet with your data on it, right-click the tab for this sheet
and select View Code from the popup menu that appears. This process will
have taken you into the VBA editor and opened the code window for the
worksheet you were just on. The next thing for you to do is Copy the code
below my signature and Paste it into the opened code window in the VBA
editor. You can now close the VBA editor and return to your worksheet. To
use this macro from the worksheet, simple press Alt+F8 and Select/Run the
CreateReports macro from the list.

Rick

Sub CreateRepeats()
Dim X As Long
Dim Y As Long
Dim LastRow As Long
Dim LastDataRow As Long
LastDataRow = 1
With ActiveSheet
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
For X = 1 To LastRow
For Y = 1 To 69 - Asc(.Cells(X, 2).Value)
Cells(LastDataRow, 3).Value = Cells(X, 1)
LastDataRow = LastDataRow + 1
Next
Next
.Range("C1").Sort Key1:=.Columns("C")
End With
End Sub