Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox wont Display

Status
Not open for further replies.

Gutierrez

Technical User
Dec 10, 2004
44
US
Hello All,
I think this problem has an easy and obvious solution .. but I just cant figure it out. I have a listbox on a spreadsheet that after the VBA code runs to add items wont display those items .. I can do it by opening another application and then coming back to the Excel worksheet ... please help .. here is the code used to load the items and them the listbox.


Public Sub Workbook_Open()

ActiveSheet.Cells(6, 8).Value = ""

Dim i As Long
Dim xTemp As Workbook
Dim xFundName As String
Dim x As Long
Dim y As Long
Dim RetVal As Variant

Range("g7") = Application.InputBox(prompt:="Please Enter Fund Name", Title:="Fund Name", Type:=2)

xFundName = ActiveSheet.Cells(7, 7)

Application.DisplayAlerts = False
Application.ScreenUpdating = False

ActiveSheet.ListBox1.Clear

Set xTemp = Workbooks.Open("P:\Proj\admin\" & xFundName & "\" & xFundName & "_security-master.xls")

i = 3

Do Until i = 30
If Cells(6, i) = "" Then
Else
ThisWorkbook.Sheets("SHEET1").ListBox1.AddItem xTemp.ActiveSheet.Cells(6, i).Value
End If
i = i + 1
Loop

xTemp.Close

RetVal = MsgBox("Would you like to add grouping?", vbQuestion + vbYesNo)
If RetVal = vbYes Then
x = 1
ActiveSheet.ListBox1.Visible = True
ActiveSheet.ListBox1.MultiSelect = fmMultiSelectSingle

ActiveSheet.Cells(6, 8) = "Select Grouping / Field(s)"
With ActiveSheet.Cells(6, 8).Font
.Bold = True
.Name = "Trebuchet MS"
.Size = 10
End With
Else
ActiveSheet.ListBox1.Visible = True
ActiveSheet.ListBox1.MultiSelect = fmMultiSelectMulti

ActiveSheet.Cells(6, 8) = "Select Grouping / Field(s)"
With ActiveSheet.Cells(6, 8).Font
.Bold = True
.Name = "Trebuchet MS"
.Size = 10
End With

x = 2
End If

Select Case x
Case 1
RetVal = MsgBox("Would you like to show subtotals?", vbQuestion + vbYesNo)
If RetVal = vbYes Then
y = 1
Else
y = 2
End If
Case 2
y = 2
End Select

ActiveSheet.Cells(1, 1).Value = y
ActiveSheet.Cells(2, 1).Value = x

MsgBox ("Please Input Period Data Before Running Macro. Thank you.")

ThisWorkbook.Sheets("SHEET1").ListBox1.AutoLoad = True

Exit Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top