删除空格我从细胞移动文本一些代码,细胞在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'' –