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

StackOverflow https://stackoverflow.com/questions/9231343

문제

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
도움이 되었습니까?

해결책

Probably something like

For Each myCell In Columns("A:A").Cells
     myCell.Value = WorksheetFunction.Trim(myCell.Value)
Next
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top