Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Referring to named ranges in a macro

I'm trying to refer to the named range "GLCodes" in a formula, as in the
following...

lngGLCode = IIF((RawHours!B2=836041), GLCodes(1,3), GLCodes(2,4))

When this formula is placed in a cell, I want the resulting value to reflect
what is in GLCodes row 1, column 3, etc.
I know this is Excel 101, and it's frustrating to not be able to make
something this (apparently) simple work. Your help will save me hours!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Referring to named ranges in a macro

Are you talking VBA or worksheet?

Assuming VBA

lngGLCode = IIF(worksheets("RawHours").Range("B2").value=83604 1), _
Range("GLCodes")(1,3), Range("GLCodes")(2,4))



--
HTH

Bob Phillips

"Pontificateur" wrote in message
...
I'm trying to refer to the named range "GLCodes" in a formula, as in the
following...

lngGLCode = IIF((RawHours!B2=836041), GLCodes(1,3), GLCodes(2,4))

When this formula is placed in a cell, I want the resulting value to

reflect
what is in GLCodes row 1, column 3, etc.
I know this is Excel 101, and it's frustrating to not be able to make
something this (apparently) simple work. Your help will save me hours!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Referring to named ranges in a macro

Since each of the cells in your named range seems to represent a specific
value, why not just give them each a name of their own?

Anyway - for your original approach:

lngGLCode = IIF((RawHours!B2=836041), INDEX(GLCodes,1,3),
INDEX(GLCodes,2,4))


Tim

--
Tim Williams
Palo Alto, CA


"Pontificateur" wrote in message
...
I'm trying to refer to the named range "GLCodes" in a formula, as in the
following...

lngGLCode = IIF((RawHours!B2=836041), GLCodes(1,3), GLCodes(2,4))

When this formula is placed in a cell, I want the resulting value to

reflect
what is in GLCodes row 1, column 3, etc.
I know this is Excel 101, and it's frustrating to not be able to make
something this (apparently) simple work. Your help will save me hours!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Referring to named ranges in a macro

Anyway - for your original approach:

lngGLCode = IIF((RawHours!B2=836041), INDEX(GLCodes,1,3),
INDEX(GLCodes,2,4))


oops that's clearly rubbish now I come back to it....

Tim

--
Tim Williams
Palo Alto, CA


"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
Since each of the cells in your named range seems to represent a specific
value, why not just give them each a name of their own?

Anyway - for your original approach:

lngGLCode = IIF((RawHours!B2=836041), INDEX(GLCodes,1,3),
INDEX(GLCodes,2,4))


Tim

--
Tim Williams
Palo Alto, CA


"Pontificateur" wrote in message
...
I'm trying to refer to the named range "GLCodes" in a formula, as in the
following...

lngGLCode = IIF((RawHours!B2=836041), GLCodes(1,3), GLCodes(2,4))

When this formula is placed in a cell, I want the resulting value to

reflect
what is in GLCodes row 1, column 3, etc.
I know this is Excel 101, and it's frustrating to not be able to make
something this (apparently) simple work. Your help will save me hours!





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Referring to named ranges in a macro

Thanks, Bob, I was indeed referring to VBA and your answer gave me exactly
what I need to get results! You are much appreciated!

"Bob Phillips" wrote:

Are you talking VBA or worksheet?

Assuming VBA

lngGLCode = IIF(worksheets("RawHours").Range("B2").value=83604 1), _
Range("GLCodes")(1,3), Range("GLCodes")(2,4))



--
HTH

Bob Phillips

"Pontificateur" wrote in message
...
I'm trying to refer to the named range "GLCodes" in a formula, as in the
following...

lngGLCode = IIF((RawHours!B2=836041), GLCodes(1,3), GLCodes(2,4))

When this formula is placed in a cell, I want the resulting value to

reflect
what is in GLCodes row 1, column 3, etc.
I know this is Excel 101, and it's frustrating to not be able to make
something this (apparently) simple work. Your help will save me hours!






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Referring to named ranges in a macro

Thanks, anyway, Tim. Your reply caused me to investigate "INDEX" and gave me
some ideas!

"Tim Williams" wrote:

Anyway - for your original approach:

lngGLCode = IIF((RawHours!B2=836041), INDEX(GLCodes,1,3),
INDEX(GLCodes,2,4))


oops that's clearly rubbish now I come back to it....

Tim

--
Tim Williams
Palo Alto, CA


"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
Since each of the cells in your named range seems to represent a specific
value, why not just give them each a name of their own?

Anyway - for your original approach:

lngGLCode = IIF((RawHours!B2=836041), INDEX(GLCodes,1,3),
INDEX(GLCodes,2,4))


Tim

--
Tim Williams
Palo Alto, CA


"Pontificateur" wrote in message
...
I'm trying to refer to the named range "GLCodes" in a formula, as in the
following...

lngGLCode = IIF((RawHours!B2=836041), GLCodes(1,3), GLCodes(2,4))

When this formula is placed in a cell, I want the resulting value to

reflect
what is in GLCodes row 1, column 3, etc.
I know this is Excel 101, and it's frustrating to not be able to make
something this (apparently) simple work. Your help will save me hours!






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
Referring to Ranges in Change-Event Macro? Wuddus Excel Discussion (Misc queries) 4 August 24th 07 08:12 PM
Referring to named ranges Hardy[_10_] Excel Programming 4 August 25th 05 12:08 PM
Macro (Print) - Calling Named Ranges KGlennC Excel Discussion (Misc queries) 1 March 19th 05 09:20 PM
Macro eliminating named ranges JonR Excel Programming 1 January 18th 05 02:03 AM
Named Ranges - Macro Problems Karl Burrows Excel Programming 2 April 4th 04 06:03 PM


All times are GMT +1. The time now is 11:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"