ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Nameing a range while still selected from copy (https://www.excelbanter.com/excel-programming/327123-nameing-range-while-still-selected-copy.html)

Jim at Eagle

Nameing a range while still selected from copy
 
I need to create a named range from an area that is still highlighted from a
copy paste special code before I lose the cell id. Is this possible?
Jim at Eagle

Toppers

Nameing a range while still selected from copy
 
Jim,

Yes ... for example ...

Range("A1:A10").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' this names the range from the copy/pastespecial i.e. A1:A10 to "MyName"
ActiveWorkbook.Names.Add Name:="MyName",
RefersToR1C1:="=Sheet1!R1C1:R10C1"

HTH

"Jim at Eagle" wrote:

I need to create a named range from an area that is still highlighted from a
copy paste special code before I lose the cell id. Is this possible?
Jim at Eagle


Jim at Eagle

Nameing a range while still selected from copy
 
Thanks,
cutcopymode:=false causes the focus to close on the range that was
established with the paste, leaving me needing to recreate the range.
This sheet3 will have 100 different range names created and the code
="=sheet1!R1C1:R10C1" will not allow for a unique name range creation.
' Locate for next copy & paste
Sheets("Storage1").Select
Sheets("Storage1").Range("A65535").End(xlUp).Offse t(1, 0).Select
Application.Goto Reference:="InvoiceBlk"
Selection.Copy
Sheets("Storage1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteColumnWidths, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

'Here is where the range is still in shade mode and I need to be
'able to assign a unique name to the area before lost of focus.

Application.CutCopyMode = False

"Toppers" wrote:

Jim,

Yes ... for example ...

Range("A1:A10").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' this names the range from the copy/pastespecial i.e. A1:A10 to "MyName"
ActiveWorkbook.Names.Add Name:="MyName",
RefersToR1C1:="=Sheet1!R1C1:R10C1"

HTH

"Jim at Eagle" wrote:

I need to create a named range from an area that is still highlighted from a
copy paste special code before I lose the cell id. Is this possible?
Jim at Eagle


macgru

Nameing a range while still selected from copy
 

Użytkownik "Jim at Eagle" napisał w
wiadomości ...
I need to create a named range from an area that is still highlighted from

a
copy paste special code before I lose the cell id. Is this possible?
Jim at Eagle



if its still selected from copy mode you can try
ActiveWorkbook.Names.Add Name:="your_name", RefersToR1C1:=Selection

you should add a number to your named range to have it done automatically
like
i=1
......
i=i+1
mcg



Jim at Eagle

Nameing a range while still selected from copy
 
That worked. Every stored invoice on sheet4 is assigned the invoice number.
Locating the range by the named allows viewing and printing. The code you
supplied will only work if sheet4 is selected. So range name is sheet
specific.
Thanks, now I can move on with frustrating myself further. Thanks again


"Macgru" wrote:


UÂżytkownik "Jim at Eagle" napisaÂł w
wiadomoÂści ...
I need to create a named range from an area that is still highlighted from

a
copy paste special code before I lose the cell id. Is this possible?
Jim at Eagle



if its still selected from copy mode you can try
ActiveWorkbook.Names.Add Name:="your_name", RefersToR1C1:=Selection

you should add a number to your named range to have it done automatically
like
i=1
......
i=i+1
mcg




macgru

Nameing a range while still selected from copy
 

Użytkownik "Jim at Eagle" napisał w
wiadomości ...
That worked. Every stored invoice on sheet4 is assigned the invoice

number.
Locating the range by the named allows viewing and printing. The code you
supplied will only work if sheet4 is selected. So range name is sheet
specific.
Thanks, now I can move on with frustrating myself further. Thanks again


"Macgru" wrote:


U?ytkownik "Jim at Eagle" napisa3

w
wiadomo?ci ...
I need to create a named range from an area that is still highlighted

from
a
copy paste special code before I lose the cell id. Is this possible?
Jim at Eagle



if its still selected from copy mode you can try
ActiveWorkbook.Names.Add Name:="your_name", RefersToR1C1:=Selection

you should add a number to your named range to have it done

automatically
like
i=1
......
i=i+1
mcg




try then sheest(...).selection
mcg




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com