Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found solution to the other questions. Thanks a lot...!! Using T(i).Type is
the best solution. It's a very powerfull tools! :)) -- Alex St-Pierre "Alex St-Pierre" wrote: I don't know why T(1).Count is not defined in the function "fSheetName". T is declared public but is not. Any idea? Option Explicit Public Type TableType Count As Integer 'For i = 1 to T(1).Count will indicate 1 To 9. Type As String 'Short Name TypeName As String 'Long Name SheetName As String Title1 As String Title2 As String Link As Boolean End Type Public iLang As Integer Public T Sub initializeT() Dim T(9) As TableType Dim aType As Variant Dim iType As Integer Dim iTable As Integer iLang = 1 'English Text aType = Array("", "T1-1", "T1-2", "T2-1", "T2-2", "T3-1", "T3-2", "T3-3", "T3-4", "T3-5") For iTable = 1 To 9 T(iTable).Count = 9 T(iTable).Type = aType(iTable) T(iTable).TypeName = Application.VLookup(aType(iTable), Sheets("data").Range("manager"), 2, 0) T(iTable).Link = True 'Voir avec VLOOKUP précédent T(iTable).Title1 = fTableTitle1(iTable) T(iTable).Title2 = fTableTitle2(iTable) If T(iTable).Link Then T(iTable).SheetName = fSheetName(T(iTable).TypeName) Next iTable iLang = 1 End Sub Function fSheetName(sType1 As String) As String Dim i As Integer On Error Resume Next i = T(1).Count For i = 1 To T(1).Count If Sheets(i).Evaluate("Type") = sType1 Then fSheetName = Sheets(i).Name: Exit For Next i On Error GoTo 0 End Function -- Alex St-Pierre "Alex St-Pierre" wrote: Hi, I have a program (form) that allow the user to create differents tables and I have too much function inside VBA that have different input and output. As example, for TableNumber = 1, there's a Type, TypeName, SheetName, Title1,Title2,... corresponding with them. Instead of using all these function (example: temp = fSheetName(TableType(1))), I could used something like T(1).SheetName. What I could do is to load the T(10) vector at the opening of the form and refer to it thereafter. Structure seems to be the right thing to simplify my program. Since my program will be used by a lot of people, I'm wondering if it is a good approach and if it can be used on any VB version? (I used 6.3). I could use a table (because all datas inside T() are string) but I prefer to write T(10).Title1 instead of T(10,3). Is there a way to say T(10).Title1 refer to element 3 inside a table T(10,3)? Thanks a lot!! -- Alex St-Pierre |