VALORE="03-03-2021_103-FATTURA ABDFKKK-.JH89.XLS"
i need to get a 2 part of string.
DATA="03-03-2021"
NR="103"
NOME="FATTURA ABDFKKK-.JH89.XLS"
VALORE, DATA, NOME and NR As dmensioned String
NOME and NR can have dinamic lenght
note:
FATTURA is a fixed part of file the rest of name are dinamic
very difficult for me... get string in string
-
- PlatinumLounger
- Posts: 4343
- Joined: 26 Apr 2010, 17:36
-
- PlatinumLounger
- Posts: 4911
- Joined: 31 Aug 2016, 09:02
Re: very difficult for me... get string in string
Try this
Code: Select all
Sub Test()
Dim x, VALORE As String
VALORE = "03-03-2021_103-FATTURA ABDFKKK-.JH89.XLS"
x = Split(VALORE, "_")
Debug.Print "Date: " & x(0)
Debug.Print "NR: " & Split(x(1), "-")(0)
Debug.Print "NOME: " & Split(x(1), "-")(1) & "-" & Split(x(1), "-")(2)
End Sub
-
- Administrator
- Posts: 78393
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: very difficult for me... get string in string
Or:
Code: Select all
Dim POS1 As Long
Dim POS2 As Long
VALORE = "03-03-2021_103-FATTURA ABDFKKK-.JH89.XLS"
POS1 = InStr(VALORE, "_")
DATA = Left(VALORE, POS1 - 1)
POS2 = InStr(POS1 + 1, VALORE, "-")
NR = Mid(VALORE, POS1 + 1, POS2 - POS1 - 1)
NOME = Mid(VALORE, POS2 + 1)
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4343
- Joined: 26 Apr 2010, 17:36
Re: very difficult for me... get string in string
Hans, YasserKhalil
Excellent!
Also to understand me:-)
Excellent!
Also to understand me:-)