在将修改后的单元格值分配回单元格时使用VBA运行时错误13'类型不匹配' [英] Using VBA Runtime error 13 'type mismatch' while assigning a modified cell value back to the cell

查看:73
本文介绍了在将修改后的单元格值分配回单元格时使用VBA运行时错误13'类型不匹配'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码在下面,给出错误,类型不匹配,运行时错误13的行是for循环中的行.为什么会发生这种情况,我该如何避免呢?

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

推荐答案

可能类似于

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

这篇关于在将修改后的单元格值分配回单元格时使用VBA运行时错误13'类型不匹配'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆