ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Designated a cell as a name range (https://www.excelbanter.com/excel-programming/338678-designated-cell-name-range.html)

Fastbike

Designated a cell as a name range
 

Can I designate the cell that I am is a "named range"?
For exmample:

Range("A1").Select
Cells.Find(What:="Involuntary Termination Count"
MatchCase:=True).Select
Selection.ClearContents
Selection.Offset(1, 0).Select

How do I program VBA to name the active cell I am in?

(I need to program this way as Involuntary Termination Count keep
moving depending on the pivot table report generated.

Thanks

--
Fastbik
-----------------------------------------------------------------------
Fastbike's Profile: http://www.excelforum.com/member.php...fo&userid=2670
View this thread: http://www.excelforum.com/showthread.php?threadid=40031


Rowan[_4_]

Designated a cell as a name range
 
Without actually selecting any cells:

Dim InvTC As Range
Dim myRange As Range
With Cells
Set InvTC = .Find(What:="Involuntary Termination Count" _
, MatchCase:=True)
End With
If Not InvTC Is Nothing Then 'checks that Involuntary Ter... was found
InvTC.ClearContents
Set myRange = InvTC.Offset(1, 0)
ActiveWorkbook.Names.Add Name:="myNamedRange", _
RefersTo:="=" & ActiveSheet.Name & "!" & myRange.Address
End If

Hope this helps
Rowan

"Fastbike" wrote:


Can I designate the cell that I am is a "named range"?
For exmample:

Range("A1").Select
Cells.Find(What:="Involuntary Termination Count",
MatchCase:=True).Select
Selection.ClearContents
Selection.Offset(1, 0).Select

How do I program VBA to name the active cell I am in?

(I need to program this way as Involuntary Termination Count keeps
moving depending on the pivot table report generated.

Thanks.


--
Fastbike
------------------------------------------------------------------------
Fastbike's Profile: http://www.excelforum.com/member.php...o&userid=26701
View this thread: http://www.excelforum.com/showthread...hreadid=400318



Fastbike[_3_]

Designated a cell as a name range
 

Great, I will try that out.

Thanks for the hel

--
Fastbik
-----------------------------------------------------------------------
Fastbike's Profile: http://www.excelforum.com/member.php...fo&userid=2670
View this thread: http://www.excelforum.com/showthread.php?threadid=40031



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com