如何将excel clmn值转换为int并将其与其他clmn变量一起重新添加并存储在excel中

时间:2013-07-08 10:32:32

标签: excel excel-vba vba

dim g as int, i as string
range("a1").value = i 
g = 10
range("b1").value = i + g 
  

让A1 = 1   预期B1 = 11但是10

2 个答案:

答案 0 :(得分:1)

dim g as int, i as string
i = range("a1").value 'assuming that A1 contains 1
g = 10
range("b1").value = i + g 

第二行分配是错误的方式

答案 1 :(得分:1)

因为我作为字符串 var(“1”),它应该是..

range("b1").value = val(i) + g