Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Syntax error (simple)

I get a compile error "Invalid use of property on the "RefersTo" method.
What am I doing wrong, please?
I am trying to set a locally defined name "Header" on each worksheet in the
workbook to refer to $AZ$102:$BH$147
within the worksheet to which the respective name is localised.

Private Sub Fixnames()
Dim wWS As Worksheet
Dim R As Range
With Application.ThisWorkbook
For Each wWS In .Worksheets
Set R = wWS.Range("$AZ$102:$BH$147")
wWS.Names("Header").RefersTo R
Next wWS
End With 'Application.ThisWorkbook
End Sub 'Fixnames()


--
Return email address is not as DEEP as it appears


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Syntax error (simple)

Wow! Instant response! thanks.

"Chip Pearson" wrote in message
...
Jack,

RefersTo is a property, so you need an equals sign to assign a
value to it.

wWS.Names("Header").RefersTo = R


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jack Schitt" wrote in
message ...
I get a compile error "Invalid use of property on the

"RefersTo" method.
What am I doing wrong, please?
I am trying to set a locally defined name "Header" on each

worksheet in the
workbook to refer to $AZ$102:$BH$147
within the worksheet to which the respective name is localised.

Private Sub Fixnames()
Dim wWS As Worksheet
Dim R As Range
With Application.ThisWorkbook
For Each wWS In .Worksheets
Set R = wWS.Range("$AZ$102:$BH$147")
wWS.Names("Header").RefersTo R
Next wWS
End With 'Application.ThisWorkbook
End Sub 'Fixnames()


--
Return email address is not as DEEP as it appears






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Syntax error (simple)

Jack,

RefersTo is a property, so you need an equals sign to assign a
value to it.

wWS.Names("Header").RefersTo = R


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jack Schitt" wrote in
message ...
I get a compile error "Invalid use of property on the

"RefersTo" method.
What am I doing wrong, please?
I am trying to set a locally defined name "Header" on each

worksheet in the
workbook to refer to $AZ$102:$BH$147
within the worksheet to which the respective name is localised.

Private Sub Fixnames()
Dim wWS As Worksheet
Dim R As Range
With Application.ThisWorkbook
For Each wWS In .Worksheets
Set R = wWS.Range("$AZ$102:$BH$147")
wWS.Names("Header").RefersTo R
Next wWS
End With 'Application.ThisWorkbook
End Sub 'Fixnames()


--
Return email address is not as DEEP as it appears




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Syntax error (simple)

If the name doesn't exist you need to add it. Assuming it does exist:

wWS.Names("Header").RefersTo = "=" & r.Address(External:=True)

--
Regards,
Tom Ogilvy


"Jack Schitt" wrote in message
...
I get a compile error "Invalid use of property on the "RefersTo" method.
What am I doing wrong, please?
I am trying to set a locally defined name "Header" on each worksheet in

the
workbook to refer to $AZ$102:$BH$147
within the worksheet to which the respective name is localised.

Private Sub Fixnames()
Dim wWS As Worksheet
Dim R As Range
With Application.ThisWorkbook
For Each wWS In .Worksheets
Set R = wWS.Range("$AZ$102:$BH$147")
wWS.Names("Header").RefersTo R
Next wWS
End With 'Application.ThisWorkbook
End Sub 'Fixnames()


--
Return email address is not as DEEP as it appears




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Syntax error (simple)

Thanks T

"Tom Ogilvy" wrote in message
...
If the name doesn't exist you need to add it. Assuming it does exist:

wWS.Names("Header").RefersTo = "=" & r.Address(External:=True)

--
Regards,
Tom Ogilvy


"Jack Schitt" wrote in message
...
I get a compile error "Invalid use of property on the "RefersTo" method.
What am I doing wrong, please?
I am trying to set a locally defined name "Header" on each worksheet in

the
workbook to refer to $AZ$102:$BH$147
within the worksheet to which the respective name is localised.

Private Sub Fixnames()
Dim wWS As Worksheet
Dim R As Range
With Application.ThisWorkbook
For Each wWS In .Worksheets
Set R = wWS.Range("$AZ$102:$BH$147")
wWS.Names("Header").RefersTo R
Next wWS
End With 'Application.ThisWorkbook
End Sub 'Fixnames()


--
Return email address is not as DEEP as it appears






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
syntax error - help Jim May Excel Discussion (Misc queries) 2 August 23rd 07 09:08 PM
question about syntax in a simple macro... Dave F Excel Discussion (Misc queries) 3 November 3rd 06 02:12 PM
Syntax error. David McNally Excel Programming 3 April 28th 04 02:57 AM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM
need help with simple syntax error Gwill Excel Programming 1 July 15th 03 08:24 AM


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