LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
PaulW
 
Posts: n/a
Default Make a new sheet if it doesn't exist

Cheers, this is working great!

"Jon Peltier" wrote:

There seems to be a line or two missing. Try this:

Sub mynewsheets()
Dim c As Range
Dim ws As Worksheet
For Each c In Range("myrange").Cells
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(c.Value)
On Error GoTo 0
If ws Is Nothing Then
Worksheets.Add.Name = c.Value
End If
Next c
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


"PaulW" wrote in message
...
Since my last post is pages behind, thought I'd repost to gain further
help.
Got this from my initial query (cheers Don Guillett)

Sub mynewsheets()
For Each c In Range("myrange")
On Error Resume Next
If Sheets.Name < c Then
Sheets.Add.Name = c
End If
Next c
End Sub

I changed myrange to Range("B2:B8") where i've put some names. When I run
the macro I get "Compile Error: Method or data member not found" and .Name
is
highlighted in the If Sheets.Name < c Then row.
Am I not loading something I should be?

Can anyone help?




 
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
Lookup function and compare Student Excel Discussion (Misc queries) 8 April 25th 06 03:11 PM
how do I make different col widths within same col. on same sheet Miker Charts and Charting in Excel 2 December 16th 05 04:57 AM
Using a relative SHEET reference for source data in a chart James Charts and Charting in Excel 6 August 16th 05 05:07 PM
How do I make excel startup in a specific sheet? Siggi Excel Worksheet Functions 2 February 18th 05 08:24 PM
Naming & renaming a sheet tab Cgbilliar Excel Worksheet Functions 1 November 7th 04 05:57 PM


All times are GMT +1. The time now is 03:53 PM.

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"