Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find & Replace: find part cell, replace whole cell | Excel Worksheet Functions | |||
Find and Replace - Replace with Blank Space | Excel Discussion (Misc queries) | |||
where to put results of find operation in find and replace functio | Excel Worksheet Functions | |||
find and replace - replace data in rows to separated by commas | Excel Worksheet Functions | |||
Replace method - cannot find any data to replace | Excel Programming |