PDA

View Full Version : Generating data using a loop



surya prakash
08-27-2007, 11:11 PM
Hi,

I am using following sub; I am not able to generate all elements;
Guess I missing outer-loop;
will appreciate any feedback...



Public Sub GenerateBU()

' Row x column
Dim m As Integer, n As Integer

Dim arr_Fla_wid() As Integer
ReDim arr_Fla_wid(11)

arr_Fla_wid(1) = 130
arr_Fla_wid(2) = 150
arr_Fla_wid(3) = 180
arr_Fla_wid(4) = 200
arr_Fla_wid(5) = 220
arr_Fla_wid(6) = 250
arr_Fla_wid(7) = 300
arr_Fla_wid(8) = 350
arr_Fla_wid(9) = 400
arr_Fla_wid(10) = 450
arr_Fla_wid(11) = 500

Dim arr_Fla_thk() As Integer
ReDim arr_Fla_thk(7)

arr_Fla_thk(1) = 6
arr_Fla_thk(2) = 8
arr_Fla_thk(3) = 10
arr_Fla_thk(4) = 12
arr_Fla_thk(5) = 14
arr_Fla_thk(6) = 16
arr_Fla_thk(7) = 20

Dim count As Integer

For m = 1 To UBound(arr_Fla_thk)

For n = 1 To UBound(arr_Fla_wid)
Cells(n, 7) = arr_Fla_thk(m) & "x" & arr_Fla_wid(n)
Next


Next


MsgBox "Data Updated"



End Sub

Bob Phillips
08-28-2007, 12:31 AM
Public Sub GenerateBU()
' Row x column
Dim m As Integer, n As Integer, i As Long

Dim arr_Fla_wid() As Integer
ReDim arr_Fla_wid(11)

arr_Fla_wid(1) = 130
arr_Fla_wid(2) = 150
arr_Fla_wid(3) = 180
arr_Fla_wid(4) = 200
arr_Fla_wid(5) = 220
arr_Fla_wid(6) = 250
arr_Fla_wid(7) = 300
arr_Fla_wid(8) = 350
arr_Fla_wid(9) = 400
arr_Fla_wid(10) = 450
arr_Fla_wid(11) = 500

Dim arr_Fla_thk() As Integer
ReDim arr_Fla_thk(7)

arr_Fla_thk(1) = 6
arr_Fla_thk(2) = 8
arr_Fla_thk(3) = 10
arr_Fla_thk(4) = 12
arr_Fla_thk(5) = 14
arr_Fla_thk(6) = 16
arr_Fla_thk(7) = 20

Dim count As Integer

For m = 1 To UBound(arr_Fla_thk)

For n = 1 To UBound(arr_Fla_wid)
i = i + 1
Cells(i, 7) = arr_Fla_thk(m) & "x" & arr_Fla_wid(n)
Next
Next

MsgBox "Data Updated"

End Sub

surya prakash
08-28-2007, 01:44 AM
thanks alot Xld...


Now I have two more arrays

WebDep = 250, 250, 300 ..... 2000 (with an increment of 50mm)
Webthk()= 4,5,6,8,10,12

I need to generate all possible combinations in the following format:
Fla_widxFla_thk + WebDepxWeb_thk

Ex: F130x6 + W200x4
Since there are four variables; does the sub require 4 loops? I am bit lost on this, can you please help...

Bob Phillips
08-28-2007, 01:58 AM
Just add extr loops, the basis is all there.

surya prakash
08-28-2007, 02:00 AM
ok, thanks; let me try and revert back....