LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Modify working code to expand the output.


This first code works excellent.

The code below it is my attempt to modify that working code to produce six 'blocks' one below the next, with the random sorted numbers incremented by 20 for each column to continue on to the last block.

Starts at 1 - 21 in first block first column so the last column in the sixth block would be 221 - 276. (hope I got the math correct)

The six lines that are commented out in the second code are the rows and MyCol is the column the subsequent blocks should be in.

I am trying to increment rowUp and rowDn for the WorksheetFunction.Transpose(b)
output. As it is the output is strange and I cannot figure how or where to make my adjustments.

Thanks,
Howard


Sub Randomizer_Description_6x20()
'/ by Claus

Dim a(19) As Variant, b, c, d, e, f
Dim Small As Integer, Big As Integer
Dim i As Long, j As Long, myCol As Long
Dim mC As Long

' Must Name the Sheet and Range for Cleaing Randomized Results.
'Sheets("Description Builder").Range("A2:A127").ClearContents
Application.ScreenUpdating = False

'1 to 6 = Number of Times to run Randomizer
For mC = 1 To 6

Small = 1
Big = 20

' 3 to 13 step 2 = Column 3 or C, Column 13 or M.

For myCol = 3 To 13 Step 2
j = 0
For i = Small To Big
a(j) = i
j = j + 1
Next
b = a: Randomize
d = UBound(b)
For c = 0 To d
e = Int(d * Rnd) + 1
f = b(c): b(c) = b(e): b(e) = f
Next

Range(Cells(2, myCol), Cells(21, myCol)) = _
WorksheetFunction.Transpose(b)

Small = Small + 20
Big = Big + 20
Next

' This is the range of the concatenated results / Sheet must be named here.
' The "B" assigns the column for special paste
' The (2) allows no blank rows between the pastespecial.
'Range("P2:P21").Copy
'Sheets("Description Builder").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Next 'mC
Application.CutCopyMode = True
Application.ScreenUpdating = True
Beep
End Sub


Sub Exp_Randomizer_Description_6x20()
'/ by Claus (modified)

Dim a(19) As Variant, b, c, d, e, f
Dim Small As Integer, Big As Integer
Dim i As Long, j As Long, myCol As Long
Dim mC As Long
Dim rowUp As Long, rowDn As Long

' Must Name the Sheet and Range for Cleaing Randomized Results.
'Sheets("Sheet1").Range("A2:A127").ClearContents
Application.ScreenUpdating = False

'1 to 6 = Number of Times to run Randomizer
For mC = 1 To 36
Range("A1") = Range("A1") + 1

' Small = The first cell ( 1 ) Big = The last cell ( 20 ) of the Title Data.
Small = 1
Big = 20
rowUp = 2
rowDn = 21

' 3 to 13 step 2 = Column 3 or C, Column 13 or O.

For myCol = 3 To 13 Step 2
j = 0
For i = Small To Big
a(j) = i
j = j + 1
Next
b = a: Randomize
d = UBound(b)
For c = 0 To d
e = Int(d * Rnd) + 1
f = b(c): b(c) = b(e): b(e) = f
Next

Range(Cells(rowUp, myCol), Cells(rowDn, myCol)) = _
WorksheetFunction.Transpose(b)

'Range(Cells(2, myCol), Cells(21, myCol)) = _
WorksheetFunction.Transpose(b)

'Range(Cells(24, myCol), Cells(43, myCol)) = _
WorksheetFunction.Transpose(b)

'Range(Cells(46, myCol), Cells(65, myCol)) = _
WorksheetFunction.Transpose(b)

'Range(Cells(68, myCol), Cells(87, myCol)) = _
WorksheetFunction.Transpose(b)

'Range(Cells(90, myCol), Cells(109, myCol)) = _
WorksheetFunction.Transpose(b)

'Range(Cells(112, myCol), Cells(131, myCol)) = _
WorksheetFunction.Transpose(b)

Small = Small + 20
Big = Big + 20
rowUp = rowUp + 22
rowDn = rowDn + 22
Next

' This is the range of the concatenated results / Sheet must be named here.
' The "B" assigns the column for special paste
' The (2) allows no blank rows between the pastespecial.

' Range("P2:P21").Copy
'Sheets("Description Builder").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Next 'mC
Application.CutCopyMode = True
Application.ScreenUpdating = True
Beep
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I modify my code to offset the defined range and repeat theprocedure instead of duplicating my code? [email protected] Excel Programming 4 May 29th 09 10:13 PM
How do I modify the default working days in excel Othman Excel Discussion (Misc queries) 1 September 6th 05 09:43 AM
Modify the official None-working days in the "NETWORKDAYS" Functio Zewer Excel Worksheet Functions 3 August 8th 05 11:27 AM
Modify sub to output to new sheet instead of via msg boxes Max Excel Programming 4 March 28th 05 03:33 PM
Output while working? Jens 'Kluesi' Kluesener Excel Programming 1 September 22nd 03 01:26 PM


All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"