Renaming a worksheet with Data pulled from a web query

bracken752

New Member
Joined
Aug 15, 2013
Messages
44
Hey all,

I have been following the forum for some time now and this is the first time I couldn't find something that hasn't already been asked before.

I'm using web queries to pull data from a website with over 300 different pages of data (a page for each user which around 4115 cell lines (which is fine as my macro only pulls 4-5 sets of web queries at a time). What I want is that when the information is pulled for the macro to rename the sheet from for example "Sheet1" to the information in cell B and C (Users First name (Cell b) and Surname (Cell C).

I have tried using the macro record to simply run through it manually, (Pull the data, create new sheet, copy cell B1:C1 and rename - paste into box) but the macro just picks up the name, so all sheets following that will be "John Smith" even though only the first sheet was called John Smith.

Any ideas?

For your information:

The code I'm using is as follows (Important URL information and names changed):

Code:
ActiveWorkbook.Worksheets.Add    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.*Removed*.net/RestrictedPages/UserDetail.aspx?userID=36", _
        Destination:=Range("$A$1"))
        .Name = "UserDetail.aspx?userID=36"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlAllTables
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
    Range("B2:C2").Select
    Selection.Copy
    Sheets("Sheet6").Select
    Sheets("Sheet6").John Smith
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
What I want is that when the information is pulled for the macro to rename the sheet from for example "Sheet1" to the information in cell B and C (Users First name (Cell b) and Surname (Cell C).

I have tried using the macro record to simply run through it manually, (Pull the data, create new sheet, copy cell B1:C1
B1 and C1? If so, try:
Code:
ActiveSheet.Name = Range("B1").Value & " " & Range("C1").Value
 
Upvote 0

Forum statistics

Threads
1,215,978
Messages
6,128,065
Members
449,417
Latest member
flovalflyer

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