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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Query Result Formatting...

Status
Not open for further replies.

Sheltered

Programmer
Nov 26, 2002
55
0
0
GB
Hi, I have a web query in Excel which gathers data from a single table on a web page.

When the data is returned it is inserted into excel over 7 rows, is there a way to format the returned data so that it is spread out on just 1 row?

The code i have so far is...
Code:
    Range("I1").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;[URL unfurl="true"]http://www.yell.com/search/DoSearch?state=INI&screen=VAL&companyName=Electrotech[/URL] Solutions&location=B77 1AG" _
        , Destination:=Range("I1"))
        .Name = _
        "DoSearch?state=INI&screen=VAL&companyName=Electrotech Solutions&location=B77 1AG"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = False
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "13"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = True
        .WebDisableDateRecognition = False
        .Refresh BackgroundQuery:=False
    End With

Thanks
Pete
 

Hey Shelter,

Try selecting your desired range, copying it and then pasting it as transposed. This, of course, is a quick fix, but it does the job. Peace!

'select your range
code yada yada blah blah
Selection.Copy 'copy
'select and empty cell to paste data as transposed
'to paste as transpose, paste-to cell must be empty
code blah blah yada
'paste selection
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
'Voila

NOTE: I noticed you are pulling repetitive data. Mainly:
TXT details
Map/Directions
Save details

The above code works well if you only select from
"Electrotech Solutions" to "Classification". If you select all data, including the "TXT details" etc., the remaining data will paste on the rows beneath "Electrotech Solutions".


Thank
You
Have
A
Nice
Day
 
Thanks tyhand, i'll have a play around with your idea :O)

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top