Excel Macro and VBA Extract the filename of a file in a Folder

  Рет қаралды 16,700

InIT Learning

InIT Learning

3 жыл бұрын

This video shows you how to find the file name of a file in a specified folder and then use that file name along with the file path in your Macro. This helps when you have created a Macro that refers to a filename but then people keep sending you the data but with different file names. This makes your macro more dynamic by allocating the file name and path to Variables in your VBA code.
SAMPLE:
Sub GetFileName()
'This will get the name of the first file in the folder
'David Ludlow InIT Learning
'One-day Excel Courses
'www.initlearning.net
Dim FileName As String
Dim PathName As String
Dim FullFileName As String
'Enter your File Path
PathName = "C:\YOURFILEPATH\"
FileName = Dir(PathName & "*.*")
FullFileName = PathName & FileName
MsgBox (FullFileName)
End Sub

Пікірлер: 8
@MartinezRBA
@MartinezRBA 11 ай бұрын
Wonderful!! It's helping me to learn VBA code, thank you very much for the information
@InITLearning
@InITLearning 4 ай бұрын
You’re very welcome
@shoaibch1234
@shoaibch1234 2 жыл бұрын
Wonderful. If i have a file name for example "data_date_time" date can be 22_2_2022 and time can be 18_00 is it possible to use the wild card only for one specific part of the file name
@manfly3614
@manfly3614 3 жыл бұрын
Super useful for a beginner like me. Thanks a lot!!
@InITLearning
@InITLearning 3 жыл бұрын
Glad it was helpful!
@MohAboAbdo
@MohAboAbdo 2 жыл бұрын
Thank you so mutch.
@InITLearning
@InITLearning 2 жыл бұрын
You're welcome!
@OneDayIllReview
@OneDayIllReview 6 ай бұрын
I want to create a macro where it extracts multiple file paths within a folder as hyperlinks - any way to do this?
Loop Through All Files in a Folder Using VBA/Macros in Excel
13:41
터키아이스크림🇹🇷🍦Turkish ice cream #funny #shorts
00:26
Byungari 병아리언니
Рет қаралды 29 МЛН
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 8 МЛН
ОДИН ДЕНЬ ИЗ ДЕТСТВА❤️ #shorts
00:59
BATEK_OFFICIAL
Рет қаралды 8 МЛН
VBA to BROWSE & COPY Data from SELECTED File in Excel
10:00
Leila Gharani
Рет қаралды 322 М.
Excel VBA | Get File Names and Details in folders and sub folders
20:03
Extreme Automation - Kamal Girdher
Рет қаралды 61 М.
VBA Open File Name with Date
11:56
The Excel Cave
Рет қаралды 5 М.
Excel VBA Code for Renaming All Files in a Folder - Excel VBA FSO
11:52
Excel Destination
Рет қаралды 32 М.
VBA to Copy File from one Folder to another Folder - Excel VBA Tutorial
10:47
Excel VBA | Export List of File Names from Folder
11:55
Essential Excel
Рет қаралды 6 М.
Loop Through Subfolders of a Folder using Excel VBA
6:51
Computergaga
Рет қаралды 14 М.
VBA - open PDF file from Microsoft Excel directly
10:20
The Data Corner
Рет қаралды 2,9 М.
터키아이스크림🇹🇷🍦Turkish ice cream #funny #shorts
00:26
Byungari 병아리언니
Рет қаралды 29 МЛН