解决VBA生成Excel单元格显示"#"的问题

因为生成的单元格的格式为Text,且数据比较多的时候会显示"##################"

所以在填充数据的时候设置下单元格的属性:

Sub WriteValue(ByVal sheet As Excel.Worksheet, ByVal rowNum As Integer, ByVal text As String, ByVal pos As String)
   Dim cell As Excel.Range
   Set cell = sheet.Range(pos & rowNum)
   cell.NumberFormat = "General"
   cell.value = text
   Set cell = Nothing
End Sub

  

你可能感兴趣的:(Excel,VBA)