刪除空格我從細胞移動文本一些代碼,細胞在VBA Excel中
Dim startIndex As Integer
Dim toIndex As Integer
Dim f As String
Dim g As String
For startIndex = 50 To 60 Step 2
toIndex = Str(startIndex + 1)
f = "F" & Str(toIndex)
g = "G" & Str(startIndex)
Range(f).Value = Range(g).Value
Range(g).Value = ""
Next startIndex
但變量f有「F 51」值,而不是「F51」。
如何解決這個問題? p.s.這是我在vba上的第一個代碼。
+1爲了解決核心問題。也可以通過使用'f =「F」&CStr(startIndex + 1)來改變'toIndex = startIndex + 1'或者去掉'toIndex'' –