ListBox Issues

Kdilas

Board Regular
Joined
Jul 11, 2002
Messages
101
Hello All,
I have several macros which paste the results from a web query into a listbox on a userform. I'm have an issue that when you scroll the listbox all of the data changes to some weird font. it looks like japaneese or something like it. Has anyone seen this issue and how can i stop it??? Thanks to all who may respond.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
How are you pasting into a listbox?

Do you mean you are populating it from the results of the web query?

If you do, how are you doing that?
 
Upvote 0
I have the following code which i put together from pieces i found on this site and the macro recorder. But as I stated the listbox seems to be going crazy!!

Code:
Private Sub UserForm_Initialize()
Dim BB As String
On Error Resume Next
Application.ScreenUpdating = False
Workbooks.Add
BB = ActiveWorkbook.Name
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Web Query"
'-----------------------------------------------------------------------------------
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://portal.scg.com/company/hitechmold/Lists/Phone%20List/Tennessee%20Phone%20List.aspx" _
        , Destination:=Range("$A$1"))
        .Name = "Tennessee%20Phone%20List"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = _
        "8,""{728E1EC5-4C6F-4713-9468-70BB90B06FCB}-{B375D5F9-2E4A-4D65-9633-B558E79C9CF1}"""
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
    Rows("2:7").Select
    Selection.Delete Shift:=xlUp
    Columns(3).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
'-----------------------------------------------------------------------------------
LastRow = Range("B" & Rows.Count).End(xlUp).Row
LastRow.Activate
        With ListBox1
            .ColumnCount = 4
            .ColumnWidths = "80;80;80;80" 'points
            .BoundColumn = 1    'if it's bound to a cell, column 2  is returned
            .ControlSource = "Web Query!A1"
            .RowSource = "B1:E1" & LastRow 'The array of cells that provide values
        End With
Workbooks(BB).Saved = True
Workbooks(BB).Close
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Is the listbox bound to a cell?

Have you tried populating it using either List or AddItem?

If you are going to use RowSource then you should probably include the worksheet name.

Also, why do you appear to be closing the workbook with the data in it?

Sorry for all the questions but when I run that code nothing really happens and I can't quite work out what you are trying to do.:)
 
Upvote 0
Hello Norie,
The Code runs in a userform. It opens a blank workbook, does the web query, populates listbox1 on the userform with the date for the user then closes the workbook. The website i am getting data from is a corporate web page which you would not have access to. I use this method to access data from our website without the user having to actually open the web page. This saves alot of time as most of our paperwork is in excel but we must also reference data on the website on a regular basis.
I do not know if the listbox is bound to a cell or not. The code works great but when you scroll the listbox the text gets all boggled up. Thats the problem.
 
Last edited:
Upvote 0
You've set all the properties you would for a bound listbox - RowSource, BoundColumn, ControlSource etc.
Why are you using a listbox?
Doesn't the data display well on a worksheet?Or is there some functionality, eg searching, filtering, you want to offer the user?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,723
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top