彼得,你的幹練指導幫助我成功(也得到了悉達特路特的幫助!):)謝謝!請在下面找到我的代碼 -
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
[你嘗試過什麼?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – 2013-03-06 08:58:37
對不起@PeterAlbert我沒有在宏觀上嘗試了任何東西。我試圖手動執行,因爲我不是宏觀方面的專家。這就是爲什麼尋求你的幫助:-) – saikosen 2013-03-06 09:49:29
嘗試宏記錄器 - 記錄你創建兩個名字的宏。然後查看代碼並嘗試修改它。向我們展示一些努力,我們很樂意爲您提供支持! – 2013-03-06 10:06:20