Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi all,
in vba - how do you tell if a named range exists? and whats the easiest way to create a named range now i am doing: Dim l As Range ActiveWorkbook.Names("LastUsed").Delete l = .Cells(Cells.Rows.Count, "C").End(xlUp)(2) ActiveWorkbook.Names.Add name:="LastUsed", _ RefersToR1C1:="='Customer Orders'!R" & l.Row & "C" & l.Column is there a better way to do this? tia J |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim nme As Name
On Error Resume Next Set nme = ActiveWorkbook.Names("holidays") On Error GoTo 0 If Not nme Is Nothing Then MsgBox "Name exists" End If Set l = .Cells(Cells.Rows.Count, "C").End(xlUp)(2) Range("'Customer Orders'!" & l.Address).Name = "LastUsed" -- HTH Bob Phillips "Gixxer_J_97" wrote in message ... hi all, in vba - how do you tell if a named range exists? and whats the easiest way to create a named range now i am doing: Dim l As Range ActiveWorkbook.Names("LastUsed").Delete l = .Cells(Cells.Rows.Count, "C").End(xlUp)(2) ActiveWorkbook.Names.Add name:="LastUsed", _ RefersToR1C1:="='Customer Orders'!R" & l.Row & "C" & l.Column is there a better way to do this? tia J |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There is no reason to tell if it exists if you want to define it. If it
already exists, it will be replace. If you want to see if it exists before using it On error resume Next set rng = Range("LastUsed") On Error goto 0 if rng is nothing then .Cells(rows.count,3).End(xlup)(2).Name = "LastUsed" End if but if that is the only reason to test, then just do .Cells(rows.count,3).End(xlup)(2).Name = "LastUsed" -- Regards, Tom Ogilvy "Gixxer_J_97" wrote in message ... hi all, in vba - how do you tell if a named range exists? and whats the easiest way to create a named range now i am doing: Dim l As Range ActiveWorkbook.Names("LastUsed").Delete l = .Cells(Cells.Rows.Count, "C").End(xlUp)(2) ActiveWorkbook.Names.Add name:="LastUsed", _ RefersToR1C1:="='Customer Orders'!R" & l.Row & "C" & l.Column is there a better way to do this? tia J |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to lookup if value exists in a range of data? | Excel Worksheet Functions | |||
inserting a named range into new cells based on a named cell | Excel Discussion (Misc queries) | |||
Check if a number exists in a range? | Excel Discussion (Misc queries) | |||
within a macro how can I suppress the warning pop "A file named xxxx.xls already exists in this location. Do you want to replace it?" | Excel Programming | |||
easy way to test if a Named Range exists | Excel Programming |