Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Names.Add - compile error

Can anyone tell me what's wrong with the following statement that is
preventing my VBA code from compiling ?

Names.Add(Name:="Base",
RefersTo:=ActiveCell.Offset(WorksheetFunction.Coun tA("$a$2:$a$60000"),6 as
range)

Thank !
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Names.Add - compile error

On Apr 17, 2:12*pm, Eric @ BP-EVV
wrote:
Can anyone tell me what's wrong with the following statement that is
preventing my VBA code from compiling ?

Names.Add(Name:="Base",
RefersTo:=ActiveCell.Offset(WorksheetFunction.Coun tA("$a$2:$a$60000"),6 as
range)

Thank !


You shouldn't need the "As Range". This worked for me:

Names.Add "Base", ActiveCell.Offset(WorksheetFunction.CountA("$A$2:$ A
$60000"),6)

Alex
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Names.Add - compile error

try this.

Sub makename()
ma = ActiveCell.Address
ActiveWorkbook.Names.Add Name:="base", RefersTo:= _
"=OFFSET(" & ma & ",COUNTA($a$2:$a$6000),6)"
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric @ BP-EVV" wrote in message
...
Can anyone tell me what's wrong with the following statement that is
preventing my VBA code from compiling ?

Names.Add(Name:="Base",
RefersTo:=ActiveCell.Offset(WorksheetFunction.Coun tA("$a$2:$a$60000"),6 as
range)

Thank !


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
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
error message: compile error, argument not optional Pierre via OfficeKB.com Excel Programming 3 September 5th 05 03:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


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