我正在尝试构建一个循环遍历单元格列的宏,并将该单元格中的两个字母国家代码替换为该国家/地区的名称。但是,当我尝试运行宏时,我得到一个对象未找到错误。Excel VBA循环遍历单元格并替换它们的值
Sub ChangeCountryText()
'
' ChangeCountryText Macro
' Changes country codes
'
For counter = 2 To 20
Set curCell = ActiveSheet.Cells(counter, 1)
Select Case curCell.Text
Case "JP"
curCell.Text = "Japan"
Case "FR"
curCell.Text = "France"
Case "IT"
curCell.Text = "Italy"
Case "US"
curCell.Text = "United States"
Case "NL"
curCell.Text = "Netherlands"
Case "CH"
curCell.Text = "Switzerland"
Case "CA"
curCell.Text = "Canada"
Case "CN"
curCell.Text = "China"
Case "IN"
curCell.Text = "India"
Case "SG"
curCell.Text = "Singapore"
End Select
Next counter
End Sub
你没有找到对象?当我测试时,curCell.Text引起了一个问题,可以通过使用curCell.Value来纠正。此代码也区分大小写。 – Fionnuala 2010-11-09 23:12:16
是的,实施该更改可解决问题。感谢您的建议。 – 2010-11-11 18:55:06