Results 1 to 5 of 5

optimise code -> subroutine to function (paramarray??!)

Threaded View

  1. #1
    Registered User
    Join Date
    08-27-2006
    Posts
    14

    optimise code -> subroutine to function (paramarray??!)

    a different one this time...

    Currently I do this:

        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
    Last edited by tozjerimiah; 11-01-2011 at 08:10 AM. Reason: title change

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1