Hellow,
I am trying to make Railway time table in excel through Visual basic. I have 2 combo Boxes (From and To)& Multiple Text Boxes to populate Train No, Train Name, Arrival & departure (TextBox 1-2-3-4) respectively. When I select Combo box 1 & 2, data is populated in all cited 4 text box correctly(1-2-3-4). But in text box no. 5-6-7-8/9-10-11-12 etc are also populated the same data as appear in text box no 1-2-3-4. Coding which I create is as below.
Request you kindly help. Thanks for your active co-operation.
Regards,
Bhawesh
I am trying to make Railway time table in excel through Visual basic. I have 2 combo Boxes (From and To)& Multiple Text Boxes to populate Train No, Train Name, Arrival & departure (TextBox 1-2-3-4) respectively. When I select Combo box 1 & 2, data is populated in all cited 4 text box correctly(1-2-3-4). But in text box no. 5-6-7-8/9-10-11-12 etc are also populated the same data as appear in text box no 1-2-3-4. Coding which I create is as below.
Code:
'Get Items to ComboBox2 based on ComboBox1 selection Private Sub ComboBox1_Change() 'Variable Declaration Dim iCnt As Integer 'Clear Combobox2 before loading items ComboBox2.Clear With ComboBox2 Select Case ComboBox1 Case "Nagpur" .AddItem "Ambala" .AddItem "Amgaon" .AddItem "Agra Cantt" .AddItem "Amravati" .AddItem "BADNERA JN" .AddItem "BADSHAHNAGAR" .AddItem "BADSHAHNAGAR" .AddItem "BAGBAHRA" End Select End With End Sub 'Get Train No based on ComboBox2 selection Private Sub ComboBox2_Change() 'Variable Declaration Dim iRow As Integer iRow = 3 'Clear Combobox2 before loading items TextBox1.Text = "" 'Get Train No based on ComboBox2 selection Do iRow = iRow + 1 Loop Until ComboBox2.Text = Sheets("Data").Cells(iRow, 3) TextBox1.Text = Sheets("Data").Cells(iRow, 4) TextBox2.Text = Sheets("Data").Cells(iRow, 5) TextBox3.Text = Sheets("Data").Cells(iRow, 6) TextBox4.Text = Sheets("Data").Cells(iRow, 7) TextBox5.Text = Sheets("Data").Cells(iRow, 4) TextBox6.Text = Sheets("Data").Cells(iRow, 5) TextBox7.Text = Sheets("Data").Cells(iRow, 6) TextBox8.Text = Sheets("Data").Cells(iRow, 7) End Sub Private Sub TextBox1_Change() End Sub Private Sub TextBox2_Change() End Sub Private Sub TextBox3_Change() End Sub Private Sub TextBox4_Change() End Sub Private Sub TextBox5_Change() End Sub Private Sub TextBox6_Change() End Sub Private Sub TextBox7_Chnge() End Sub Private Sub TextBox8_Change() End
Regards,
Bhawesh
Comment