Using VBA Runtime error 13 'type mismatch' while assigning a modified cell value back to the cell

核能气质少年 提交于 2020-01-15 15:58:44

问题


My code is below, the line that gives the error, type mismatch, runtime error 13 is the line within the for loop. WHy is this happening and how can I avoid it?

Workbooks(theFile).Worksheets(1).Columns("G:G").EntireColumn.NumberFormat = "0.00"

For Each myCell In Columns("G:G")
    myCell.Value = WorksheetFunction.Trim(WorksheetFunction.Clean(myCell.Value))
Next

回答1:


Probably something like

For Each myCell In Columns("A:A").Cells
     myCell.Value = WorksheetFunction.Trim(myCell.Value)
Next


来源:https://stackoverflow.com/questions/9231343/using-vba-runtime-error-13-type-mismatch-while-assigning-a-modified-cell-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!