计算特定文件夹中的文件,并将其显示为1 cel [英] count files in specific folder and display the number into 1 cel
本文介绍了计算特定文件夹中的文件,并将其显示为1 cel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道1个特定文件夹中扩展名为.xls的文件有多少个. 我阅读了带有消息框的数百个示例,但这不是我想要的. 我只想将数字显示为1 cel.
请问有人愿意帮助我吗? 我无法发布任何尝试,因为我无法开始:-(
致以最诚挚的问候, E.解决方案
尝试以下代码:
在运行下面的代码之前,将文件夹的路径分配给变量FolderPath
.
Sub sample()
Dim FolderPath As String, path As String, count As Integer
FolderPath = "C:\Documents and Settings\Santosh\Desktop"
path = FolderPath & "\*.xls"
Filename = Dir(path)
Do While Filename <> ""
count = count + 1
Filename = Dir()
Loop
Range("Q8").Value = count
'MsgBox count & " : files found in folder"
End Sub
I am trying to know how many files there are in 1 specific folder with .xls extension. I read hundreds of examples with message boxes, but that is not what I'm looking for. I just want to have the number displayed into 1 cel.
Is there someone who likes to help me with that please? I can not post any attempts because I can not get started :-(
best regards, E.
解决方案
Try below code :
Assign the path of the folder to variable FolderPath
before running the below code.
Sub sample()
Dim FolderPath As String, path As String, count As Integer
FolderPath = "C:\Documents and Settings\Santosh\Desktop"
path = FolderPath & "\*.xls"
Filename = Dir(path)
Do While Filename <> ""
count = count + 1
Filename = Dir()
Loop
Range("Q8").Value = count
'MsgBox count & " : files found in folder"
End Sub
这篇关于计算特定文件夹中的文件,并将其显示为1 cel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文