View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Victor Delta[_2_] Victor Delta[_2_] is offline
external usenet poster
 
Posts: 199
Default Help with an Excel macro please?

In article ,
says...

Hi,

Am Sun, 27 Apr 2014 08:55:56 +0200 schrieb Claus Busch:

try:

Sub Randomize()


if you want to fill the exact number of rows like shown in C1 try:

Sub Randomize()
Dim arrOut As Variant
Dim LRow As Long
Dim myRows As Long

With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

With ActiveSheet
myRows = .Range("C1")
Do
LRow = .Cells(Rows.Count, "B").End(xlUp).Offset(1, 0).Row
arrOut = .Range("A1:A" & WorksheetFunction.Min(6, myRows - LRow
+ 1))
.Range("B" & IIf(LRow = 2, 1, LRow)) _
.Resize(rowsize:=UBound(arrOut)) = arrOut
.Calculate
Loop While LRow + 6 < myRows
End With

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With

End Sub


Regards
Claus B.


Claus

Your second macro works perfectly, thank you so much.

However, there is one final modification I would like to make if it's
possible. Rather than copying the sets of numbers straight down column
B, I would like to only copy them to those rows where the cells of
column E contain a 'Y'. So if C1 was 15, the 15 numbers might actually
be spread down a much greater number of rows.

Hope this makes sense and many thanks if you can tell me how to do this.

V