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!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744196690a4562690.html
评论列表(0条)