asyamonique
Well-known Member
- Joined
- Jan 29, 2008
- Messages
- 1,286
- Office Version
- 2013
- Platform
- Windows
Code:
Private Sub CommandButton16_Click()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlManual
Worksheets("0600").Visible = True
If FileExists("C:\me\0600.xls") Then
Workbooks.Open Filename:="C:\me\0600.xls"
Range("A:A,M:M,N:N,Q:Q").Select
Range("Q1").Activate
Selection.Copy
Windows("Result.xls").Activate
Sheets("0600").Select
Columns("A:A").Select
ActiveSheet.Paste
Columns("D:D").Select
Application.CutCopyMode = False
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
Windows("0600.xls").Activate
ActiveWindow.Close False
End If
Dim a, i As Long, ii As Long, b(), n As Long
With ComboBox1
If .Text = "" Then Exit Sub
If WorksheetFunction.CountIf(Worksheets("0600").Range("a:a"), .Text) = 0 Then
Exit Sub
End If
a = Worksheets("0600").Range("a1").Resize(Worksheets("0600").Range("a" & Rows.Count).End(xlUp).Row, 26).Value
For i = 1 To UBound(a, 1)
If a(i, 1) = .Text Then
n = n + 1: ReDim Preserve b(1 To 26, 1 To n)
For ii = 1 To UBound(a, 2)
b(ii, n) = a(i, ii)
Next
End If
Next
End With
With ListBox1
.ColumnCount = 26
.ColumnWidths = "0;50;80;50;50;50;50,50;50;50;50;50;50,50;50;50;50;50;50,50;50;50;50;50;50,50"
.Column = b
End With
Sheet4.Select
On Error Resume Next
With Me.ListBox1
Me.TextBox1.Value = Me.ListBox1.Column(1, 0)
Me.TextBox2.Value = Me.ListBox1.Column(1, 1)
Me.TextBox3.Value = Me.ListBox1.Column(1, 2)
Me.TextBox4.Value = Me.ListBox1.Column(1, 3)
Me.TextBox5.Value = Me.ListBox1.Column(1, 4)
Me.TextBox6.Value = Me.ListBox1.Column(1, 5)
Me.TextBox7.Value = Me.ListBox1.Column(1, 6)
Me.TextBox8.Value = Me.ListBox1.Column(1, 7)
Me.TextBox9.Value = Me.ListBox1.Column(1, 8)
Me.TextBox10.Value = Me.ListBox1.Column(1, 9)
Me.TextBox11.Value = Me.ListBox1.Column(1, 10)
Me.TextBox12.Value = Me.ListBox1.Column(1, 11)
Me.TextBox13.Value = Me.ListBox1.Column(1, 12)
Me.TextBox14.Value = Me.ListBox1.Column(1, 13)
Me.TextBox15.Value = Me.ListBox1.Column(1, 14)
Me.TextBox16.Value = Me.ListBox1.Column(1, 15)
Me.TextBox17.Value = Me.ListBox1.Column(1, 16)
Me.TextBox18.Value = Me.ListBox1.Column(1, 17)
Me.TextBox19.Value = Me.ListBox1.Column(1, 18)
Me.TextBox20.Value = Me.ListBox1.Column(1, 19)
Me.TextBox21.Value = Me.ListBox1.Column(3, 0)
Me.TextBox22.Value = Me.ListBox1.Column(3, 1)
Me.TextBox23.Value = Me.ListBox1.Column(3, 2)
Me.TextBox24.Value = Me.ListBox1.Column(3, 3)
Me.TextBox25.Value = Me.ListBox1.Column(3, 4)
Me.TextBox26.Value = Me.ListBox1.Column(3, 5)
Me.TextBox27.Value = Me.ListBox1.Column(3, 6)
Me.TextBox28.Value = Me.ListBox1.Column(3, 7)
Me.TextBox29.Value = Me.ListBox1.Column(3, 8)
Me.TextBox30.Value = Me.ListBox1.Column(3, 9)
Me.TextBox31.Value = Me.ListBox1.Column(3, 10)
Me.TextBox32.Value = Me.ListBox1.Column(3, 11)
Me.TextBox33.Value = Me.ListBox1.Column(3, 12)
Me.TextBox34.Value = Me.ListBox1.Column(3, 13)
Me.TextBox35.Value = Me.ListBox1.Column(3, 14)
Me.TextBox36.Value = Me.ListBox1.Column(3, 15)
Me.TextBox37.Value = Me.ListBox1.Column(3, 16)
Me.TextBox38.Value = Me.ListBox1.Column(3, 17)
Me.TextBox39.Value = Me.ListBox1.Column(3, 18)
Me.TextBox40.Value = Me.ListBox1.Column(3, 19)
End With
Dim varTotal As Currency
Dim varRow As Integer
For varRow = 0 To (ListBox1.ListCount - 1)
varTotal = varTotal + ListBox1.Column(2, varRow)
Next
Me.TextBox724.Value = varTotal
Dim arTotal As Currency
Dim arRow As Integer
For arRow = 0 To (ListBox1.ListCount - 1)
arTotal = arTotal + ListBox1.Column(3, arRow)
Next
Me.TextBox725.Value = arTotal
Me.TextBox418.Value = TextBox724.Value
Me.TextBox381.Value = TextBox725.Value
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
ctl.Value = Format(ctl.Value, "$#,##0.000")
End If
Next ctl
Worksheets("0600").Visible = False
Application.Calculation = xlAutomatic
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Good Day,
In regards given code above im having error.
The listbox populates the combobox index.Its filtering the column A values into the listbox.And the textboxes fills with related columns.
This code works only when its run on 'wiev code' windows(Alt+F11)other wise its hang!!
Is it possible that someone will tell me the reason why?