Find a character and assign a variable to that character and the following 15 characters

S Oberlander

Board Regular
Joined
Nov 25, 2020
Messages
147
Office Version
  1. 365
Platform
  1. Windows
I am trying to find the first "5" in a text string and assign a variable that should include the 5 and the 15 characters following it.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Maybe
VBA Code:
   Dim Txt As String, Txt2 As String
   
   Txt = "abc123589pwertyukfskffk"
   Txt2 = Mid(Txt, InStr(1, Txt, "5"), 16)
 
Upvote 0
Solution
Maybe
VBA Code:
   Dim Txt As String, Txt2 As String
  
   Txt = "abc123589pwertyukfskffk"
   Txt2 = Mid(Txt, InStr(1, Txt, "5"), 16)
Thanks!
edited to:
VBA Code:
   Dim Merch As String, MerchId As String
   
   Merch = Range("A1")
   MerchId = Mid(Merch, InStr(1, Merch, "5"), 16)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top