是否有 Excel 公式可以忽略文件名的前几个字符?
我想问是否有可能有一个Excel公式(或者可能是一个宏)可以删除文件名的前几个字符(但是,字符数各不相同......见下文)。我对 VBA 的经验有限,尽管在 python 或 java 中,我可以看到如何使用 while 循环。
例如,我使用的一些文件名包括(其中 XXXX 是我要保留的文件的名称):
S00.002-2-XXXXXXXXXXXXXXX
S05.051[4]-XXXXXXXXXXXXXXX
S03.025[P4]- XXXXXXXXXXXXXXX
12345-S01.132[CC]-XXXXXXXXXXX
此外,XXXXXXX 表示的文件名始终以字母开头,以便将是循环终止的时间(或者更确切地说,循环将在文件名之前的“-”之后终止)。
正如您所看到的,文件名由于使用的命名约定不同而有所不同,这意味着“for”循环可能不是更好的选择。
截至目前,我主要在Excel上使用MID()公式(即=MID(B3,16,50)),这需要我在每次命名约定发生变化时更改公式的中间数字(因此占用了大量时间)。
I want to ask if it is possible for there to be a Excel formula (or perhaps a macro) which can remove the first few characters of a file name (however, the number of characters varies...see below). I have limited experience with VBA although in python or java, I could see how a while loop may be used.
For example, some of the file names I am using include (where XXXX is the name of the file that I want to keep):
S00.002-2-XXXXXXXXXXXXXXX
S05.051[4]-XXXXXXXXXXXXXXX
S03.025[P4]-XXXXXXXXXXXXXXX
12345-S01.132[CC]-XXXXXXXXXXX
Additionally, the file names represented by the XXXXXXX always start with a letter so that would be when the loop would terminate (or rather, the loop would terminate after the '-' before the file name).
As you can see, the file names vary due to the different naming conventions that are used, which means that a 'for' loop is probably not preferable.
As of right now, I have been mainly using the MID() formula on Excel (i.e.=MID(B3,16,50)) which requires me to change the middle number of the formula every time there is a change in the naming convention (and thus uses up a lot of time).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
=MID([Cell],FIND("-",[Cell])+1,256) 将提取分隔符后的所有文本。
您想对文件名做什么?
=MID([Cell],FIND("-",[Cell])+1,256) will extract all text after the delimiter.
What are you wanting to do with the file name?