我得到一個運行時錯誤「13」:在下面的代碼Set tempChar = Range(Cells(iSourceRow, 31), Cells(iSourceRow, 31))
行類型不匹配:如何在Excel VBA中將單元格的文本內容分配給變量?
Sub GetStratGoalResponses()
'
' GetStratGoalResponses Macro
'
' Keyboard Shortcut: Ctrl g
'
Dim iSourceRow As Integer
Dim iTargetRow As Integer
Dim tempChar As Characters
iTargetRow = 1
For iSourceRow = 2 To 28
Worksheets("Survey_Responses_Oct_12,_2015").Activate
If Range(Cells(iSourceRow, 31), Cells(iSourceRow, 31)) = "" Then End
Set tempChar = Range(Cells(iSourceRow, 31), Cells(iSourceRow, 31))
MsgBox "About to process Strategic Goal Response ", tempChar
Range(Cells(iSourceRow, 31), Cells(iSourceRow, 31)).Select
Selection.Copy
Worksheets("Strategic Goal Parsed").Activate
Range("A2").Select
ActiveSheet.Paste
Set tempChar = Range("A2")
MsgBox "Just pasted response of ", tempChar
Range("A4:A9").Select
Selection.Copy
Range(Cells(iTargetRow, 53), Cells(iTargetRow, 53)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A2:A2").Select
Selection.Clear
iTargetRow = iTargetRow + 6
Next iSourceRow
End Sub
你宣佈'tempChar'爲'character'不'range'閱讀範圍()值。 – findwindow