Obtaining Values from Filenames

  • Thread starter DLinkage
  • Start date
In summary, to extract specific characters from a file's filename and append them to a range of cells, you can use the mid function in VB. The 'Office Development' forum within the VB forum is a useful resource for additional help.
  • #1
DLinkage
19
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
  • #2
Do some string manipulations i guess...I forgot my vb :(
 
  • #4
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:

FAQ: Obtaining Values from Filenames

What is the purpose of "Obtaining Values from Filenames: A Guide"?

The purpose of "Obtaining Values from Filenames: A Guide" is to provide a comprehensive guide for scientists on how to extract meaningful data and values from filenames. This can be particularly useful for researchers who deal with large amounts of data and need to organize and analyze it efficiently.

What types of data can be obtained from filenames?

Data such as dates, times, locations, experiment numbers, and sample identifiers can be obtained from filenames. The specific data that can be extracted will depend on the naming conventions used by the researcher or the institution.

Why is it important to have a guide for obtaining values from filenames?

Having a guide for obtaining values from filenames can save time and improve data organization. It can also help to avoid errors and inconsistencies in data analysis, as well as facilitate data sharing and collaboration among scientists.

Are there any limitations to using filenames for obtaining values?

Yes, there can be limitations depending on the naming conventions used and the complexity of the data. In some cases, filenames may not contain all the necessary information and additional data may need to be recorded separately. It is important for scientists to carefully plan and design their naming conventions to ensure the most relevant data can be obtained from filenames.

Is there a recommended approach for obtaining values from filenames?

There is not one specific approach that is recommended for all situations. However, it is generally recommended to use a consistent and logical naming convention, make use of date and time stamps, and include all relevant information in the filename. It may also be helpful to create a guide or template for naming files to ensure consistency and accuracy.

Similar threads

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