|
-
Aug 11th, 2010, 04:04 PM
#1
Thread Starter
Addicted Member
[RESOLVED] how do i split the word
for example i have "journal id expired on - Jul 5/10
i need the part Ju 5/ 10
ie after "-"
how to write in vba code
thanks for your help
-
Aug 11th, 2010, 04:22 PM
#2
Re: how do i split the word
try like
vb Code:
mystr = "journal id expired on - Jul 5/10" mystr = mid(mystr, instr(mystr, "-" + 1))
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 11th, 2010, 04:55 PM
#3
Re: how do i split the word
One more way... Using Split()
Code:
Sub Sample()
Dim StrSample As String, MyArray() As String
StrSample = "journal id expired on - Jul 5/10"
MyArray = Split(StrSample, "-")
MsgBox MyArray(1)
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 11th, 2010, 05:42 PM
#4
Thread Starter
Addicted Member
Re: how do i split the word
hi Kool and westconn
both i tried it gives type mismatch
-
Aug 11th, 2010, 05:43 PM
#5
Re: how do i split the word
Show us the exact code that you are using?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 11th, 2010, 05:52 PM
#6
Thread Starter
Addicted Member
Re: how do i split the word
Kool
sorry i missed MyArray () as string
thanks it works fine. i need another help
how do compare MyArray with Cell(a)
Cell (a) = 08/15/2010 8:18
thanks
-
Aug 11th, 2010, 05:57 PM
#7
Re: how do i split the word
I am sorry, I do not understand. Can you explain it a bit more on what you want to do?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 11th, 2010, 06:04 PM
#8
Thread Starter
Addicted Member
Re: how do i split the word
for example
compareMyarray to Cell (1)
MyArray as string and Cell(1) format as m/d/yyyy h:mm
how do i compare both
-
Aug 11th, 2010, 06:19 PM
#9
Re: how do i split the word
You mean if Cell say A1 has "7/5/2010 8:18:00" and you want to compare the value stored in the array then do this...
Code:
Sub Sample()
Dim StrSample As String, MyArray() As String, Temp As String
StrSample = "journal id expired on - Jul 5/10"
MyArray = Split(StrSample, "-")
'~~> A1 = 7/5/2010 8:18:00
Temp = Trim(Format(Range("A1"), "mmm d/yy"))
If Trim(MyArray(1)) = Temp Then
MsgBox "match found"
Else
MsgBox "match not found"
End If
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|