VBA忽略系统分离器设置在打开CSV文件上
在我的Windows OS中,我使用以下分隔符设置“日期,时间或数字格式”:
十进制:“,”
Milesimal:“。”
列表: ”;”
在excel中,我设置为文件>选项>高级使用系统分离器(ticked)
并且当我手动打开CSV文件时,它根据系统分离器(由于机密数据而隐藏的数据)。在下图中,每个数据在一个列中
问题1:
但是当我要求我的VBA宏打开此CSV文件时,它完全忽略了系统分离器。在下图中,所有数据均在“ a
&“ \
.VALUE
” @foxfireandburnsandburns):
添加了本地属性:= workbooks.open(macrofile.range(“ b”& i)。值),updateLinks:= false,local:= true
问题2:
当我要求我的VBA宏关闭+保存此CSV文件时,它完全忽略了系统分离器。它取代了所有“”;使用“,”列表定义器
我在VBA中使用的命令关闭+保存文件为:
workbooks(macrofile.range(“ c”& i).value).value).close savechanges:= true
问题3:
我也注意到,当我尝试使用下面的公式命令时,它也无效,即使将分隔符为“”;
file_csv.range(“ z1”)。公式=“ = sumif(f:f;”“ c”“; g:g)”
我必须替换:
file> file_csv.range( “ z1”)。公式=“ = sumif(f:f,”“ c”,g:g)“
问题3的解决方案(timwilliams的荣誉):
二手。 (“ z1”)。formulaCal =“ = sumif(f:f;”“ c”“; g:g)”
In my Windows OS, I set my "Date, time or number formats" with the following separators:
Decimal: ","
Milesimal: "."
List: ";"
In excel, I set in File > Options > Advanced > Use System Separators (ticked)
And when I open my CSV file manually, it goes according to the System Separators (data hidden due to confidential data). In the picture below, each data is in one Column
PROBLEM 1:
But when I asked my VBA macro to Open this CSV file, it totally ignored the System Separators. In the picture below, all data are in the Column A
The command I used in VBA to open the file was:
Workbooks.Open (MacroFile.Range("B" & i).Value & "\" & MacroFile.Range("C" & i).Value), UpdateLinks:=False
Note: It gets the Path + FileName through Cell Content
SOLUTION FOR PROBLEM 1 (credit to @FoxfireAndBurnsAndBurns):
Added property Local:=True to Workbooks.Open (MacroFile.Range("B" & i).Value & "\" & MacroFile.Range("C" & i).Value), UpdateLinks:=False, Local:=True
PROBLEM 2:
When I asked my VBA macro to Close+Save this CSV file, it totally ignored the System Separators. It replaced all the ";" with "," list delimiters
The command I used in VBA to Close+Save the file was:
Workbooks(MacroFile.Range("C" & i).Value).Close SaveChanges:=True
PROBLEM 3:
I've noticed too that when I tried to use the Formula command below, it didn't work, even having Separator as ";"
File_CSV.Range("Z1").Formula = "=SUMIF(F:F;""C"";G:G)"
I had to replace for:
File_CSV.Range("Z1").Formula = "=SUMIF(F:F,""C"",G:G)"
SOLUTION FOR PROBLEM 3 (Credit for TimWilliams):
Used .FormulaLocal in File_CSV.Range("Z1").FormulaLocal = "=SUMIF(F:F;""C"";G:G)"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论