Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default find and replace in vba

I need vba to look at ie A1 and look if there is a "/" and replace it with
"-", but it must not return that value in the cell. I want to use the value
and a named range This what i have done so far.

Sub ParentNamedRange()

Dim ParentNamedRange
' set Parent Named range


ParentStockcCode = ???????????

Range("M6:M10").Select
ActiveWorkbook.Names.Add Name:=ParentNamedRange,
RefersToR1C1:="=R6C13:R10C13"
End Sub

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default find and replace in vba

Sub MacParentNamedRange()

Dim ParentNamedRange as Range
dim ParentStockCode as String

set parentnamedrange = worksheets("sheet99").range("a1")

parentstockcode = parentnamedrange.value

'but - is not valid in a name, either--so I used an underscor
parentstockcode = replace(parentstockcode,"/","_")
'or if you're using xl97
parentstockcode = application.substitute(parentstockcode,"/","_")

ActiveWorkbook.Names.Add Name:=Parentstockcode, _
RefersToR1C1:="=R6C13:R10C13"

End Sub

And it's not a good idea to name a variable the same as your subroutine.

lasca wrote:

I need vba to look at ie A1 and look if there is a "/" and replace it with
"-", but it must not return that value in the cell. I want to use the value
and a named range This what i have done so far.

Sub ParentNamedRange()

Dim ParentNamedRange
' set Parent Named range


ParentStockcCode = ???????????

Range("M6:M10").Select
ActiveWorkbook.Names.Add Name:=ParentNamedRange,
RefersToR1C1:="=R6C13:R10C13"
End Sub

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default find and replace in vba

Hi thanks.

What would this command be if it is not a given sheet but the current
worksheet ?

set parentnamedrange = worksheets("sheet99").range("a1")

Thanks for pointing out the other errors!




"Dave Peterson" wrote:

Sub MacParentNamedRange()

Dim ParentNamedRange as Range
dim ParentStockCode as String

set parentnamedrange = worksheets("sheet99").range("a1")

parentstockcode = parentnamedrange.value

'but - is not valid in a name, either--so I used an underscor
parentstockcode = replace(parentstockcode,"/","_")
'or if you're using xl97
parentstockcode = application.substitute(parentstockcode,"/","_")

ActiveWorkbook.Names.Add Name:=Parentstockcode, _
RefersToR1C1:="=R6C13:R10C13"

End Sub

And it's not a good idea to name a variable the same as your subroutine.

lasca wrote:

I need vba to look at ie A1 and look if there is a "/" and replace it with
"-", but it must not return that value in the cell. I want to use the value
and a named range This what i have done so far.

Sub ParentNamedRange()

Dim ParentNamedRange
' set Parent Named range


ParentStockcCode = ???????????

Range("M6:M10").Select
ActiveWorkbook.Names.Add Name:=ParentNamedRange,
RefersToR1C1:="=R6C13:R10C13"
End Sub

Thanks


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default find and replace in vba

set parentnamedrange = Activesheet.range("a1")



lasca wrote:

Hi thanks.

What would this command be if it is not a given sheet but the current
worksheet ?

set parentnamedrange = worksheets("sheet99").range("a1")

Thanks for pointing out the other errors!

"Dave Peterson" wrote:

Sub MacParentNamedRange()

Dim ParentNamedRange as Range
dim ParentStockCode as String

set parentnamedrange = worksheets("sheet99").range("a1")

parentstockcode = parentnamedrange.value

'but - is not valid in a name, either--so I used an underscor
parentstockcode = replace(parentstockcode,"/","_")
'or if you're using xl97
parentstockcode = application.substitute(parentstockcode,"/","_")

ActiveWorkbook.Names.Add Name:=Parentstockcode, _
RefersToR1C1:="=R6C13:R10C13"

End Sub

And it's not a good idea to name a variable the same as your subroutine.

lasca wrote:

I need vba to look at ie A1 and look if there is a "/" and replace it with
"-", but it must not return that value in the cell. I want to use the value
and a named range This what i have done so far.

Sub ParentNamedRange()

Dim ParentNamedRange
' set Parent Named range


ParentStockcCode = ???????????

Range("M6:M10").Select
ActiveWorkbook.Names.Add Name:=ParentNamedRange,
RefersToR1C1:="=R6C13:R10C13"
End Sub

Thanks


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default find and replace in vba

Thank you very much!


"Dave Peterson" wrote:

set parentnamedrange = Activesheet.range("a1")



lasca wrote:

Hi thanks.

What would this command be if it is not a given sheet but the current
worksheet ?

set parentnamedrange = worksheets("sheet99").range("a1")

Thanks for pointing out the other errors!

"Dave Peterson" wrote:

Sub MacParentNamedRange()

Dim ParentNamedRange as Range
dim ParentStockCode as String

set parentnamedrange = worksheets("sheet99").range("a1")

parentstockcode = parentnamedrange.value

'but - is not valid in a name, either--so I used an underscor
parentstockcode = replace(parentstockcode,"/","_")
'or if you're using xl97
parentstockcode = application.substitute(parentstockcode,"/","_")

ActiveWorkbook.Names.Add Name:=Parentstockcode, _
RefersToR1C1:="=R6C13:R10C13"

End Sub

And it's not a good idea to name a variable the same as your subroutine.

lasca wrote:

I need vba to look at ie A1 and look if there is a "/" and replace it with
"-", but it must not return that value in the cell. I want to use the value
and a named range This what i have done so far.

Sub ParentNamedRange()

Dim ParentNamedRange
' set Parent Named range


ParentStockcCode = ???????????

Range("M6:M10").Select
ActiveWorkbook.Names.Add Name:=ParentNamedRange,
RefersToR1C1:="=R6C13:R10C13"
End Sub

Thanks

--

Dave Peterson


--

Dave Peterson



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
Find & Replace: find part cell, replace whole cell katy Excel Worksheet Functions 3 April 3rd 23 01:20 PM
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
where to put results of find operation in find and replace functio DEP Excel Worksheet Functions 5 November 15th 06 07:52 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Replace method - cannot find any data to replace Mike Excel Programming 5 April 6th 06 08:56 PM


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