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
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