Obtaining Values from Filenames

  • Thread starter Thread starter DLinkage
  • Start date Start date
AI Thread Summary
To extract specific parts of a filename in VBA, such as the numbers "12" and "13" from filenames like "ABC12X.txt" and "ABC13X.txt," string manipulation functions can be utilized. The Mid function is particularly useful for this purpose. For example, using Mid(s1, 4, 2) allows you to retrieve the 4th and 5th characters of the string, effectively extracting the desired numeric values. For further assistance and resources, the 'Office Development' forum on VBForums is recommended for additional support in VBA programming.
DLinkage
Messages
17
Reaction score
0
I'm trying to read in a file's filename and append part of the filename to a certain range of cells. This is to say if the filename was "ABC12X.txt"
and another filename was "ABC13X.txt", then how could I obtain the values "12" and "13" given the filename information alone? Thanks
 
Technology news on Phys.org
Do some string manipulations i guess...I forgot my vb :(
 
DLinkage said:
I'm trying to read in a file's filename and append part of the filename to a certain range of cells. This is to say if the filename was "ABC12X.txt"
and another filename was "ABC13X.txt", then how could I obtain the values "12" and "13" given the filename information alone? Thanks

If what you are trying to extract is always the 4th-5th characters, you can use the mid function:

Sub test()
Dim s1 As String
s1 = "ABC12X.txt"
Debug.Print Mid(s1, 4, 2) 'result is 12
End Sub


If you need addition help, the 'Office Development' forum within the following VB forum is great:

http://www.vbforums.com/index.php

Good luck. :smile:
 
Last edited:
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
10
Views
2K
Replies
18
Views
6K
Replies
4
Views
9K
Replies
4
Views
2K
Replies
3
Views
5K
Back
Top