admin管理员组文章数量:1399269
I currently have a macro that opens a file and moves data around. Within the file being opened there are numbers in column A that have been formatted as text to avoid excel reformatting them (e.g. '1234123412341234). If I open that file by double clicking on it (i.e. not using the macro) then those cells remain as text and I can see the full numbers. However, if I run the macro the cells always reformat (see screenshot for what I mean).
I've tried so many ways to get the macro to open the file and not reformat the cells, but I am now stuck.
This is the code I normally use:
' pop up to choose file
myFile = Application.GetOpenFilename
' check a file was chosen correctly
If myFile = "False" Then Exit Sub
If TypeName(myFile) = "Boolean" Then Exit Sub
' open the file
Workbooks.Open myFile
Is anyone aware of a way to open the file (it is a CSV) using VBA without this reformatting happening? I need the full numbers to be available for some of the remaining steps in the macro to work with.
Thank you!
本文标签: excelVBAOpen a file using a macro without reformatting cellsStack Overflow
版权声明:本文标题:excel - VBA - Open a file using a macro without reformatting cells - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744196689a2594774.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论