ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming Ranges with code (https://www.excelbanter.com/excel-programming/404604-naming-ranges-code.html)

Les

Naming Ranges with code
 
Hello all, i have a report that has rows added to it and it has both a
columnm that is a range name, so the new cell has to be added to the range
and secondly within that range the cell has it's own name dependant on what
the user puts in.

C D E
Desc. Code P/O

Bonnet Hood "HoodPo"Range name
Bumper(Font) BF "BFPo"
Bumper(Rear) BR "BRPo"
Front end FRT "FRTPo"
IMC-SAS IMC "IMCPo"
New Part Test "TestPo"-- New range Name for cell.

The old PORange in column "E" (E1:E5) must expand to (E1:E6)

The "code" will be put in by the user.


--
Les

Don Guillett

Naming Ranges with code
 
More info. However, probably best to have the name defined by the offset
formula

insertnamedefinename itin the refers to box type
=offset($C$1,1,0,counta($C:$C)-1,1)
Now when you add/subtract a row of info the range will auto adjust.
For the data, user can input or use a macro using inputbox

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Les" wrote in message
...
Hello all, i have a report that has rows added to it and it has both a
columnm that is a range name, so the new cell has to be added to the range
and secondly within that range the cell has it's own name dependant on
what
the user puts in.

C D E
Desc. Code P/O

Bonnet Hood "HoodPo"Range name
Bumper(Font) BF "BFPo"
Bumper(Rear) BR "BRPo"
Front end FRT "FRTPo"
IMC-SAS IMC "IMCPo"
New Part Test "TestPo"-- New range Name for cell.

The old PORange in column "E" (E1:E5) must expand to (E1:E6)

The "code" will be put in by the user.


--
Les



Per Jessen[_2_]

Naming Ranges with code
 
On 19 Jan., 12:07, Les wrote:
Hello all, i have a report that has rows added to it and it has both a
columnm that is a range name, so the new cell has to be added to the range
and secondly within that range the cell has it's own name dependant on what
the user puts in.

* * C * * * * * * * * * *D * * * * * E
*Desc. * * * * * * * Code * * * P/O

Bonnet * * * * * * *Hood * * *"HoodPo"Range name
Bumper(Font) * *BF * * * * *"BFPo"
Bumper(Rear) * BR * * * * * "BRPo"
Front end * * * * *FRT * * * *"FRTPo"
IMC-SAS * * * * * IMC * * * *"IMCPo"
New Part * * * * * Test * * * "TestPo"-- New range Name for cell.

The old PORange in column "E" (E1:E5) must expand to (E1:E6)

The "code" will be put in by the user.

--
Les


Hi Les

Put this in the code sheet for the desired worksheet

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vName As String
Dim tRange As Range
If Target.Column = 4 Then
vName = Target.Value
Set tRange = Range("E1", Cells(Target.Row, 4))
vName = vName & "Po"
tRange.Name = vName
Target.Offset(0, 1) = vName
End If
End Sub

// Per


All times are GMT +1. The time now is 07:08 PM.

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