Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Creating range name based on cell value.

Sheet named “Summary” contains a range name “TempNumber”.

I need a macro that will, within the current sheet, go to cell A1. It
will look at the range TempNumber and name the range (of cell A1) a
combination of the word “Vehicle” plus the value in TempNumber.

Example: The value in range TempNumber is "Test1".
This macro will cause Cell A1 of whatever the current sheet is to be
named “Vehicle Test1”
This will be used in different sheets, so I need it to do this in
whatever the Current Sheet is.

Thanks
j.o.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Creating range name based on cell value.

use the INDIRECT() function

Activesheet.Range("A1").Name = "Vehicle" &
worksheets("Summary").Range("TempNumber").Value



"jeff" wrote:

Sheet named €śSummary€ť contains a range name €śTempNumber€ť.

I need a macro that will, within the current sheet, go to cell A1. It
will look at the range TempNumber and name the range (of cell A1) a
combination of the word €śVehicle€ť plus the value in TempNumber.

Example: The value in range TempNumber is "Test1".
This macro will cause Cell A1 of whatever the current sheet is to be
named €śVehicle Test1€ť
This will be used in different sheets, so I need it to do this in
whatever the Current Sheet is.

Thanks
j.o.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,722
Default Creating range name based on cell value.

I believe you're looking for something like this:

Sub NameRange()

'Get Named Value
x = Range(ActiveWorkbook.Names("TempNumber"))

'Create Named Range
'Note that you can't have a space in name
ActiveWorkbook.Names.Add Name:="Vehicle" & x, _
RefersToR1C1:="=" & ActiveSheet.Name & "!R1C1"
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"jeff" wrote:

Sheet named €śSummary€ť contains a range name €śTempNumber€ť.

I need a macro that will, within the current sheet, go to cell A1. It
will look at the range TempNumber and name the range (of cell A1) a
combination of the word €śVehicle€ť plus the value in TempNumber.

Example: The value in range TempNumber is "Test1".
This macro will cause Cell A1 of whatever the current sheet is to be
named €śVehicle Test1€ť
This will be used in different sheets, so I need it to do this in
whatever the Current Sheet is.

Thanks
j.o.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Creating range name based on cell value.

On Sep 3, 10:23*am, Luke M wrote:
I believe you're looking for something like this:

Sub NameRange()

'Get Named Value
x = Range(ActiveWorkbook.Names("TempNumber"))

'Create Named Range
'Note that you can't have a space in name
ActiveWorkbook.Names.Add Name:="Vehicle" & x, _
RefersToR1C1:="=" & ActiveSheet.Name & "!R1C1"
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*



"jeff" wrote:
Sheet named “Summary” contains a range name “TempNumber”.


I need a macro that will, within the current sheet, go to cell A1. It
will look at the range TempNumber and name the range (of cell A1) a
combination of the word “Vehicle” plus the value in TempNumber.


Example: The value in range TempNumber is "Test1".
This macro will cause Cell A1 of whatever the current sheet is to be
named “Vehicle Test1”
This will be used in different sheets, so I need it to do this in
whatever the Current Sheet is.


Thanks
j.o.- Hide quoted text -


- Show quoted text -


Thanks for both solutions.
I'm getting an error when it comes to this part (same error on the
solution from Patrick).

ActiveWorkbook.Names.Add Name:="Vehicle" & x, _
RefersToR1C1:="=" & ActiveSheet.Name & "!R1C1"

I'll play around with this some more, but maybe there's something
obvious somebody can spot in the syntax.
Thanks
j.o.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Creating range name based on cell value.

What error are you getting?

Both Patrick's and Luke's code work fine for me.:)



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
creating columns based on date range childofthe1980s Excel Worksheet Functions 0 April 17th 08 06:25 PM
creating columns based on date range childofthe1980s Excel Programming 0 April 17th 08 06:04 PM
Creating a range name based on cell content not being a negative value. burl_h Excel Programming 5 November 28th 06 06:01 AM
suggestions on creating a text value based on a date range Allen Clark Setting up and Configuration of Excel 0 June 28th 06 02:44 AM
Creating recordsets based on a range PO Excel Programming 1 December 11th 03 11:51 AM


All times are GMT +1. The time now is 07:21 AM.

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"