VBA忽略系统分离器设置在打开CSV文件上

发布于 2025-02-01 07:59:28 字数 1546 浏览 2 评论 0原文

在我的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: ";"

enter image description here

In excel, I set in File > Options > Advanced > Use System Separators (ticked)

enter image description here

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

enter image description here


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

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文