Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Worksheet name in cell

I have a procedure creating new worksheets and naming them according to a list.(Courtesy
of Debra Dalgleish's site) the relevant part of which is shown below.
What I am trying to do is to add a line where I have indicated to put the new sheet name
into cell Q1 in each new sheet. I am failing miserably in what I thought was very
straightforward. The sheet is not active so I cannot use Activesheet.name and attempts at
Range("Q1").value = c.Value fail miserably. Any help much appreciated.

Else
Set wsNew = Sheets.Add
wsNew.Move After:=Worksheets(Worksheets.Count)
wsNew.Name = c.Value

rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sheet1").Range("L1:L2"), _
CopyToRange:=wsNew.Range("A1"), _
Unique:=False
End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Worksheet name in cell

Else
Set wsNew = Sheets.Add
wsNew.Move After:=Worksheets(Worksheets.Count)
wsNew.Name = c.Value
wsNew.Range("Q1").Value = wsNew.Name
rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sheet1").Range("L1:L2"), _
CopyToRange:=wsNew.Range("A1"), _
Unique:=False
End If

--
__________________________________
HTH

Bob

"Graham H" wrote in message
...
I have a procedure creating new worksheets and naming them according to a
list.(Courtesy of Debra Dalgleish's site) the relevant part of which is
shown below.
What I am trying to do is to add a line where I have indicated to put the
new sheet name into cell Q1 in each new sheet. I am failing miserably in
what I thought was very straightforward. The sheet is not active so I
cannot use Activesheet.name and attempts at Range("Q1").value = c.Value
fail miserably. Any help much appreciated.

Else
Set wsNew = Sheets.Add
wsNew.Move After:=Worksheets(Worksheets.Count)
wsNew.Name = c.Value

rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sheet1").Range("L1:L2"), _
CopyToRange:=wsNew.Range("A1"), _
Unique:=False
End If



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Worksheet name in cell

How have you defined the range "c"? Add this to your code before defining
the WSname. Also, there are restrictions on what can go into a worksheet
name. Some characters aren't allowed.

debug.print c.parent.name, c.address, c.value

to see if there's anything in the range c
--
HTH,
Barb Reinhardt



"Graham H" wrote:

I have a procedure creating new worksheets and naming them according to a list.(Courtesy
of Debra Dalgleish's site) the relevant part of which is shown below.
What I am trying to do is to add a line where I have indicated to put the new sheet name
into cell Q1 in each new sheet. I am failing miserably in what I thought was very
straightforward. The sheet is not active so I cannot use Activesheet.name and attempts at
Range("Q1").value = c.Value fail miserably. Any help much appreciated.

Else
Set wsNew = Sheets.Add
wsNew.Move After:=Worksheets(Worksheets.Count)
wsNew.Name = c.Value

rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sheet1").Range("L1:L2"), _
CopyToRange:=wsNew.Range("A1"), _
Unique:=False
End If

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Worksheet name in cell

Oops, for some reason I overlooked the question you asked. DOH!

Barb Reinhardt



"Barb Reinhardt" wrote:

How have you defined the range "c"? Add this to your code before defining
the WSname. Also, there are restrictions on what can go into a worksheet
name. Some characters aren't allowed.

debug.print c.parent.name, c.address, c.value

to see if there's anything in the range c
--
HTH,
Barb Reinhardt



"Graham H" wrote:

I have a procedure creating new worksheets and naming them according to a list.(Courtesy
of Debra Dalgleish's site) the relevant part of which is shown below.
What I am trying to do is to add a line where I have indicated to put the new sheet name
into cell Q1 in each new sheet. I am failing miserably in what I thought was very
straightforward. The sheet is not active so I cannot use Activesheet.name and attempts at
Range("Q1").value = c.Value fail miserably. Any help much appreciated.

Else
Set wsNew = Sheets.Add
wsNew.Move After:=Worksheets(Worksheets.Count)
wsNew.Name = c.Value

rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sheet1").Range("L1:L2"), _
CopyToRange:=wsNew.Range("A1"), _
Unique:=False
End If

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Worksheet name in cell

Thanks to both for your help. It is much appreciated.

Graham

Barb Reinhardt wrote:
Oops, for some reason I overlooked the question you asked. DOH!

Barb Reinhardt



"Barb Reinhardt" wrote:

How have you defined the range "c"? Add this to your code before defining
the WSname. Also, there are restrictions on what can go into a worksheet
name. Some characters aren't allowed.

debug.print c.parent.name, c.address, c.value

to see if there's anything in the range c
--
HTH,
Barb Reinhardt



"Graham H" wrote:

I have a procedure creating new worksheets and naming them according to a list.(Courtesy
of Debra Dalgleish's site) the relevant part of which is shown below.
What I am trying to do is to add a line where I have indicated to put the new sheet name
into cell Q1 in each new sheet. I am failing miserably in what I thought was very
straightforward. The sheet is not active so I cannot use Activesheet.name and attempts at
Range("Q1").value = c.Value fail miserably. Any help much appreciated.

Else
Set wsNew = Sheets.Add
wsNew.Move After:=Worksheets(Worksheets.Count)
wsNew.Name = c.Value

rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sheet1").Range("L1:L2"), _
CopyToRange:=wsNew.Range("A1"), _
Unique:=False
End If



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Worksheet name in cell

Are you sorted?

--
__________________________________
HTH

Bob

"Graham H" wrote in message
...
Thanks to both for your help. It is much appreciated.

Graham

Barb Reinhardt wrote:
Oops, for some reason I overlooked the question you asked. DOH!

Barb Reinhardt



"Barb Reinhardt" wrote:

How have you defined the range "c"? Add this to your code before
defining the WSname. Also, there are restrictions on what can go into a
worksheet name. Some characters aren't allowed.
debug.print c.parent.name, c.address, c.value

to see if there's anything in the range c
--
HTH,
Barb Reinhardt



"Graham H" wrote:

I have a procedure creating new worksheets and naming them according to
a list.(Courtesy of Debra Dalgleish's site) the relevant part of which
is shown below.
What I am trying to do is to add a line where I have indicated to put
the new sheet name into cell Q1 in each new sheet. I am failing
miserably in what I thought was very straightforward. The sheet is not
active so I cannot use Activesheet.name and attempts at
Range("Q1").value = c.Value fail miserably. Any help much appreciated.

Else
Set wsNew = Sheets.Add
wsNew.Move After:=Worksheets(Worksheets.Count)
wsNew.Name = c.Value

rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sheet1").Range("L1:L2"), _
CopyToRange:=wsNew.Range("A1"), _
Unique:=False
End If



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Worksheet name in cell

Bob Phillips wrote:
Are you sorted?

Yes Bob, many thanks for coming back. The problem really was with the rest of the code
which I didn't notice. The procedure created new worksheets and copied filtered data to
these. When it was re-run if the sheets already existed the procedure cleared all the
cells in the sheet and entered the filtered data. The bit of code I wanted altered was
when a new sheet was added and yes, you guessed it, I was trying all the permutations when
all the sheets were already there and consequently the code for this part was ignored! I
had taken Debras code for the whole thing and should have paid more attention. I am
grateful for you checking up.

Graham
Reply
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
link a cell in the 'Master' worksheet list to a 'Detail' worksheet Paul Condron Excel Programming 12 July 16th 06 10:41 PM
copy data in a cell from worksheet A to worksheet B rajesh Excel Discussion (Misc queries) 1 February 21st 06 07:40 AM
How can I link cell colours from worksheet to worksheet/workbook? Evelyn Excel Worksheet Functions 1 July 5th 05 09:16 PM
selecting cell range in other worksheet without switching to worksheet suzetter[_4_] Excel Programming 4 June 22nd 05 08:55 PM
Worksheet reference (i.e placing worksheet name in a cell) Roger Roger Excel Worksheet Functions 1 January 20th 05 03:40 PM


All times are GMT +1. The time now is 02:23 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"