ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming cells using VBA (https://www.excelbanter.com/excel-programming/352595-naming-cells-using-vba.html)

Inspector Gadget[_3_]

Naming cells using VBA
 
I'm very new to creating VBA code so what I would like help with is this
problem. I'm trying to create a name for a cell that incorporates another
cell contents and the words "Grand_Total_".

My thoughts are along the lines of trying to develop code that creates the
new name that I want (e.g Grand_Total_Bandage) by joining the cell with the
contents of 'Bandage' to the words "Grand_Total_" and then use this for the
cell name. What I can't work out is how to reference the contents of the
cell I want and then add it to the Grand_Total_. I'm pretty sure I know how
to add the results to the other cell that I want to name using VBA code.

Any assistance would be most appreciated.

Insp G



Norman Jones

Naming cells using VBA
 
Hi Gadget,

Try something like:

'=============
Public Sub Tester()
Const sStr As String = "Grand_Total_"

Range("A1").Name = sStr & Range("B1").Value
End Sub
'<<=============


---
Regards,
Norman



"Inspector Gadget " <oakey**<<REMOVE wrote in message
...
I'm very new to creating VBA code so what I would like help with is this
problem. I'm trying to create a name for a cell that incorporates another
cell contents and the words "Grand_Total_".

My thoughts are along the lines of trying to develop code that creates the
new name that I want (e.g Grand_Total_Bandage) by joining the cell with
the
contents of 'Bandage' to the words "Grand_Total_" and then use this for
the
cell name. What I can't work out is how to reference the contents of the
cell I want and then add it to the Grand_Total_. I'm pretty sure I know
how
to add the results to the other cell that I want to name using VBA code.

Any assistance would be most appreciated.

Insp G





Inspector Gadget[_3_]

Naming cells using VBA
 
Thanks for the tip I'll give it a go.

"Norman Jones" wrote in message
...
Hi Gadget,

Try something like:

'=============
Public Sub Tester()
Const sStr As String = "Grand_Total_"

Range("A1").Name = sStr & Range("B1").Value
End Sub
'<<=============


---
Regards,
Norman



"Inspector Gadget " <oakey**<<REMOVE wrote in message
...
I'm very new to creating VBA code so what I would like help with is this
problem. I'm trying to create a name for a cell that incorporates

another
cell contents and the words "Grand_Total_".

My thoughts are along the lines of trying to develop code that creates

the
new name that I want (e.g Grand_Total_Bandage) by joining the cell with
the
contents of 'Bandage' to the words "Grand_Total_" and then use this for
the
cell name. What I can't work out is how to reference the contents of the
cell I want and then add it to the Grand_Total_. I'm pretty sure I know
how
to add the results to the other cell that I want to name using VBA code.

Any assistance would be most appreciated.

Insp G








All times are GMT +1. The time now is 10:31 AM.

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