tozjerimiah
New Member
- Joined
- Nov 1, 2011
- Messages
- 3
Currently I do this:
Code:
I want to optimise this by turning it into a function; basically it extracts data from a table based on parameters...
You will notice that each of the above conditions only use 2 parameters, however I would like to be able to pass the function any number... so what I'm thinking is basically:
allBrick = functionname(table (search_one, search_two), (search_one, search_three, search_four))
I guess that the function would return an array...
I hope that this makes sense... knowing that what I am wanting to do is possible would be a great start!!
Thanks
Code:
Code:
For CurrentTableRow = WallTableBeginsRow To WallTableBeginsRow + NumberOfWalls
If (Cells(CurrentTableRow, BwkBlkStudCol).Value = "Bwk") And (Cells(CurrentTableRow, FloorCol).Value = "GF") Then
GFBWKArrayNumber = GFBWKArrayNumber + 1
ReDim Preserve GFBWK(1 To GFBWKArrayNumber)
GFBWK(GFBWKArrayNumber) = (Cells(CurrentTableRow, LengthCol).Value) & " * " & (Cells(CurrentTableRow, HeightCol).Value)
ElseIf _
(Cells(CurrentTableRow, BwkBlkStudCol).Value = "Blk") And (Cells(CurrentTableRow, FloorCol).Value = "GF") Then
GFBLKArrayNumber = GFBLKArrayNumber + 1
ReDim Preserve GFBLK(1 To GFBLKArrayNumber)
GFBLK(GFBLKArrayNumber) = (Cells(CurrentTableRow, LengthCol).Value) & " * " & (Cells(CurrentTableRow, HeightCol).Value)
ElseIf _
(Cells(CurrentTableRow, BwkBlkStudCol).Value = "Bwk") And (Cells(CurrentTableRow, FloorCol).Value = "FF") Then
FFBWKArrayNumber = FFBWKArrayNumber + 1
ReDim Preserve FFBWK(1 To FFBWKArrayNumber)
FFBWK(FFBWKArrayNumber) = (Cells(CurrentTableRow, LengthCol).Value) & " * " & (Cells(CurrentTableRow, HeightCol).Value)
ElseIf _
(Cells(CurrentTableRow, BwkBlkStudCol).Value = "Blk") And (Cells(CurrentTableRow, FloorCol).Value = "FF") Then
FFBLKArrayNumber = FFBLKArrayNumber + 1
ReDim Preserve FFBLK(1 To FFBLKArrayNumber)
FFBLK(FFBLKArrayNumber) = (Cells(CurrentTableRow, LengthCol).Value) & " * " & (Cells(CurrentTableRow, HeightCol).Value)
ElseIf _
(Cells(CurrentTableRow, BwkBlkStudCol).Value = "Bwk") And (Cells(CurrentTableRow, FloorCol).Value = "TOP") Then
TOPBWKArrayNumber = TOPBWKArrayNumber + 1
ReDim Preserve TOPBWK(1 To TOPBWKArrayNumber)
TOPBWK(TOPBWKArrayNumber) = (Cells(CurrentTableRow, LengthCol).Value) & " * (" & (Cells(CurrentTableRow, HeightCol).Value) & " /2)"
ElseIf _
(Cells(CurrentTableRow, BwkBlkStudCol).Value = "Blk") And (Cells(CurrentTableRow, FloorCol).Value = "TOP") Then
TOPBLKArrayNumber = TOPBLKArrayNumber + 1
ReDim Preserve TOPBLK(1 To TOPBLKArrayNumber)
TOPBLK(TOPBLKArrayNumber) = (Cells(CurrentTableRow, LengthCol).Value) & " * (" & (Cells(CurrentTableRow, HeightCol).Value) & " /2)"
Else: End If
Next CurrentTableRow
I want to optimise this by turning it into a function; basically it extracts data from a table based on parameters...
You will notice that each of the above conditions only use 2 parameters, however I would like to be able to pass the function any number... so what I'm thinking is basically:
allBrick = functionname(table (search_one, search_two), (search_one, search_three, search_four))
I guess that the function would return an array...
I hope that this makes sense... knowing that what I am wanting to do is possible would be a great start!!
Thanks