PC Review


Reply
Thread Tools Rate Thread

Add Sheet Name to Cell in Worksheet

 
 
=?Utf-8?B?cGxvZGRpbmdnYWx0bg==?=
Guest
Posts: n/a
 
      20th Oct 2006
I would like to add the sheet name to cell H in the worksheet but only those
rows that have text in them. How would I do that with code? Thanks
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      20th Oct 2006
Have text where in the row? Anywhere or in a single columnn

assume column G and the text are constants

set rng = columns(7).specialcells(xlconstants,xltextvalues)
set rng1 = Intersect(rng.entireRow, Columns(8))
rng1.Value = Activesheet.name

--
Regards,
Tom Ogilvy


"ploddinggaltn" wrote:

> I would like to add the sheet name to cell H in the worksheet but only those
> rows that have text in them. How would I do that with code? Thanks

 
Reply With Quote
 
Sandy
Guest
Posts: n/a
 
      20th Oct 2006
do you mean column H and text in any cell in the row?

If so:

Sub AddSheetName()
Dim mCell As Range, mRow As Range
For Each mCell In Range("H:H")
For Each mRow In Range(mCell, _
Cells(mCell.Row, Columns.Count).End(xlToLeft).Address)
If Not mRow.Value = Empty Then
mCell.Value = ActiveSheet.Name
End If
Next mRow
Next mCell
End Sub


Sandy


ploddinggaltn wrote:
> I would like to add the sheet name to cell H in the worksheet but only those
> rows that have text in them. How would I do that with code? Thanks


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to get the worksheet name in a cell in each sheet T. Valko Microsoft Excel Discussion 0 13th Aug 2008 04:00 AM
Reference to a worksheet name in a cell on another sheet Howard Kaikow Microsoft Excel Discussion 3 13th Apr 2008 05:13 AM
Using cell as worksheet name to return data on that sheet =?Utf-8?B?Um9va2llX1VzZXI=?= Microsoft Excel Worksheet Functions 4 28th Jan 2007 06:27 AM
copy cell from one sheet of worksheet to another sheet =?Utf-8?B?UGxhbmV0amlt?= Microsoft Excel Misc 1 10th Jan 2006 09:36 AM
Urgent help with cell from one worksheet to another work sheet =?Utf-8?B?TmVlZGhlbHBpblRlbm5lc3NlZQ==?= Microsoft Excel Worksheet Functions 2 7th Sep 2004 11:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:39 AM.