View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
jnewl jnewl is offline
external usenet poster
 
Posts: 28
Default assign a name to a cell using vb

i have multi tabs on a series of worksheets. i am inserting a column at the
beginning of each worksheet and then populating that column with the name on
the tab. i want to name the column in "a1", fee sched id.

i tried what you suggested but i get an error. 'name not found error"

what am i doing wrong


Sub fixdata()
Dim wks As Worksheet
Dim mycol As Long
Dim lastrow As Long
Dim mycell As Range
mycol = 1
For Each wks In ActiveWorkbook.Worksheets
With wks
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Columns(mycol).Insert
.Range(.Cells(1, mycol), .Cells(lastrow, mycol)).Value = "'" & wks.Name
Set mycell = ActiveSheet.Range("A1")
mycell.Name = "fee sched id"
End With
Next wks
End Sub

thanks



"Dave Peterson" wrote:

Dim myCell as range
set mycell = activesheet.range("x9")
mycell.name = "avalidnamehere"



jnewl wrote:

what is the code to assign a name to a cell using vb?
thanks


--

Dave Peterson