Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Name.Add problem

I am trying to set a range based on a fixed first cell and finding the last
cell in the column with data and assigning it a variable name to be used in
the Selection.add.name code. The string variable displays the correct range
when I step through it but does not work in the Find statement. What have I
done wrong?
Thank you.

'Set cells for range name
Dim strLastInA As String
Range("A6500").Select
Selection.End(xlUp).Select
strLastInA = "A4:" & ActiveCell.Address

ActiveSheet.Names.Add Name:="RepUnitAbbr", RefersTo:=strLastInA
'
Cells.Range(RepUnitAbbr).Replace What:="SBMU", Replacement:="S ",
Lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, searchformat:=False, _
ReplaceFormat:=False
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Name.Add problem

TRy this

'Set cells for range name
Range(Range("A4"), Range("A" & Rows.Count).End(xlUp)).Name =
"RepUnitAbbr"
'
Range(RepUnitAbbr).Replace What:="SBMU", _
Replacement:="S ", _
Lookat:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
searchformat:=False, _
ReplaceFormat:=False

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Billy B" wrote in message
...
I am trying to set a range based on a fixed first cell and finding the last
cell in the column with data and assigning it a variable name to be used
in
the Selection.add.name code. The string variable displays the correct
range
when I step through it but does not work in the Find statement. What have
I
done wrong?
Thank you.

'Set cells for range name
Dim strLastInA As String
Range("A6500").Select
Selection.End(xlUp).Select
strLastInA = "A4:" & ActiveCell.Address

ActiveSheet.Names.Add Name:="RepUnitAbbr", RefersTo:=strLastInA
'
Cells.Range(RepUnitAbbr).Replace What:="SBMU", Replacement:="S ",
Lookat:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, searchformat:=False, _
ReplaceFormat:=False



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
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 04:32 PM.

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

About Us

"It's about Microsoft Excel"