Hi maninweb, I have written the code to get the joining condition for the particular table, it is joined to but i am not getting the desired output
In the first loop i am getting all the tables which the user selects in the userform.
Code:
Option Explicit
Public join_array(25)
Public SourceWB as WorkBook
Public Sub get_join()
Dim lngIndex As Long
Dim temp As String
Dim temp1 As String
Dim Rowcount As Long
Dim Index As Long
Dim strValue As String
Dim i As Long
Dim j As Long
Set SourceWB = Workbooks.Open("C:\Data.xlsx", False, True)
With SourceWB.Worksheets("condition")
Rowcount = .Cells(.Rows.Count, "B").End(xlUp).Row
'Testing...
MsgBox "Rowcount"
'Loop...
For lngIndex = 0 To UBound(table_array)
strValue = table_array(lngIndex)
MsgBox strValue
For Index = 1 To Rowcount
If Not strValue <> .Cells(Index, 1).Value Then
temp = CStr(Index)
temp1 = .Cells(temp, 2).Value
MsgBox temp1
For i = 0 To UBound(table_array)
If temp1 = table_array(i) Then
join_array(j) = Application.WorksheetFunction.VLookup(temp1, Range("A:C"), 3, False)
MsgBox join_array(j)
j = j + 1
End If
Next i
End If
Next Index
Next lngIndex
End With
End Sub
In the first loop i am getting all the tables which the user selects in the userform.