我的要求是创建一个macro
,其中将使用(功能区>公式>名称管理器)excel 2010
自动为等距单元格分配或创建名称。Name Manager
For e.g. Cell A1 to be named as Name_1, Cell A11 to be named as Name_2, Cell A21 to be named as Name_3 and so on.
希望这是有道理的,否则要求澄清。谢谢!
彼得,您的干练指导帮助我取得了成功(也得到了 Siddharth Rout 的帮助!):) 谢谢!请在我的代码下面找到 -
Private Sub CommandButton1_Click()
'Define the variables
Dim vRangeDefined, vRowCount, vRowIndex, vColIndex, vCounter, vCellValue As String, vNameValue As String
'Define the range where the values are entered
vRangeDefined = ActiveSheet.Range("A:B").Value
vRowCount = ActiveSheet.UsedRange.Rows.Count
For vCounter = 2 To vRowCount
vCellValue = vRangeDefined(vCounter, 1)
vNameValue = vRangeDefined(vCounter, 2)
'Divide the Cell Value in two parts
vRowIndex = Left(vCellValue, 1)
vColIndex = Right(vCellValue, Len(vCellValue) - 1)
'MsgBox vRowIndex & "-" & vColIndex
'Assign the names to cells as per the range
ActiveWorkbook.Names.Add _
Name:=vNameValue, _
RefersTo:="='Sheet1'!$" & vRowIndex & "$" & vColIndex
Next
MsgBox "Process complete..."
End Sub