LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Naming worksheets based on a cell value

I'm trying to import hockey stats into a spreadsheet.

The first part of the query works great but I want to name the worksheet
based on the player (the name is imported into cell A1).

I'm not sure why this code isn't working. Any help would be appreciated.

For Each ws In Worksheets
ws.Name = Range("A1").Value
Next ws


The entire query is below for your reference.

Thanks,



Sub Macro1()
' Macro1 Macro
' Macro recorded 4/25/2007 by David White
Dim i As Long
Dim ws As Worksheet
i = 100

Do While i < 110
Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.hockeydb.com/ihdb/stats/pdisplay.php3?pid=" & i,
Destination _
:=Range("A1"))
.Name = "HockeyDB"
.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 = xlWebFormattingAll
.WebTables = "5,6"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
i = i + 1
Debug.Print Range("A1").Value
Loop

For Each ws In Worksheets
ws.Name = Range("A1").Value
Next ws

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming worksheets tabs from another cell reference Finance Guru Excel Worksheet Functions 2 July 1st 09 07:00 PM
Creating/Naming New Worksheets Based on Select Cells in Master Worksheet Lilbit Excel Worksheet Functions 2 March 19th 08 05:05 PM
naming a file based on cell value? nokia3650 Excel Programming 2 August 3rd 06 07:13 AM
cuting sheet and naming it based on value in specific cell? nokia3650 Excel Programming 0 August 1st 06 02:41 PM
naming .xls file based on a cell in excel lsu-i-like Excel Discussion (Misc queries) 1 June 24th 05 09:44 PM


All times are GMT +1. The time now is 10:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"