Use the Instr function
Dim pos As Integer pos = InStr("find the comma, in the string", ",")
will return 15 in pos
If not found it will return 0
If you need to find the comma with an excel formula you can use the =FIND(",";A1)
function.
Notice that if you want to use Instr
to find the position of a string case-insensitive use the third parameter of Instr and give it the const vbTextCompare
(or just 1 for die-hards).
Dim posOf_A As Integer posOf_A = InStr(1, "find the comma, in the string", "A", vbTextCompare)
will give you a value of 14.
Note that you have to specify the start position in this case as stated in the specification I linked: The start argument is required if compare is specified.
Related Posts:
- What does <> mean?
- How to find a value in an excel column by vba code Cells.Find
- VBScript to open a dialog to select a filepath
- Does VBA have Dictionary Structure?
- “Sub or Function not defined” when trying to run a VBA script in Outlook
- What is the function of FormulaR1C1?
- What exactly is the function of Application.CutCopyMode property in Excel
- VBA Excel – Insert row below with same format including borders and frames
- Deleting a file in VBA
- Excel VBA: Can’t get a match, error “Unable to get the Match property of the WorksheetFunction class”
- How to comment and uncomment blocks of code in the Office VBA Editor
- Run-time error ‘3061’. Too few parameters. Expected 1. (Access 2007)
- Pass arguments to Constructor in VBA
- How to install Date Picker form control in Excel 2016
- How to install Date Picker form control in Excel 2016
- How to fill color in a cell in VBA?
- Refreshing all the pivot tables in my excel workbook with a macro
- VBA: Run time error ’91’?
- Compare Dates in VBA
- What is the difference between “Form Controls” and “ActiveX Control” in Excel 2010?
- ‘Cannot find DAO350.dll’ file error VB6
- Average in VBA in Excel
- VBA Excel “Compile error: Object Required”
- Choosing paper size (NOT DEFAULT sizes) in excel vba
- “Unable to get the VLookup property of the WorksheetFunction Class” error [duplicate]
- Paste Special error 1004 PasteSpecial method of Range class failed
- VBA: Getting run-time 1004: Method ‘Range’ of object ‘_Worksheet’ failed when using cells
- Cannot run the macro… the macro may not be available in this workbook
- How do I lowercase a string in Python?
- How do I convert a String to an int in Java?
- How to format strings in Java
- How do I get a substring of a string in Python?
- Substring in excel
- Does Python have a string ‘contains’ substring method?
- Why the switch statement cannot be applied on strings?
- How does strtok() split the string into tokens in C?
- Convert bytes to a string
- Java – Convert integer to string [duplicate]
- Replacing instances of a character in a string
- Changing one character in a string
- How to read a file line-by-line into a list?
- What is lexicographical order?
- strip(char) on a string
- How to convert string to char array in C++?
- How can I convert a std::string to int?
- How to convert list to string [duplicate]
- Easiest way to convert int to string in C++
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- How to check whether a string contains a substring in JavaScript?
- Check if a string has a certain piece of text [duplicate]
- Converting integer to string in Python
- Reverse a string in Python
- How to split a string in Java
- How do I compare strings in Java?
- How to replace all occurrences of a string in JavaScript
- How do I compare two strings in python?
- std::string to char*
- How can I convert String to Int?
- How to convert a string to an integer in JavaScript?
- How to convert string to char array in C++?
- How to convert an int to string in C?
- C++ — expected primary-expression before ‘ ‘
- How can I do string interpolation in JavaScript?
- How to convert a char to a String?
- Regex not operator
- How to convert/parse from String to char in java?
- C++ string to double conversion
- How do I make the first letter of a string uppercase in JavaScript?
- Reverse a string in Java
- working of \n in python [duplicate]
- ValueError: could not convert string to float: id
- How do I make the first letter of a string uppercase in JavaScript?
- Regex not operator
- Print string to text file
- Reverse a string in Java
- What is a string of hexadecimal digits?
- Best way to convert string to bytes in Python 3?
- Pythonic way to create a long multi-line string
- Best way to convert string to bytes in Python 3?
- Does Python have a string ‘contains’ substring method?
- Extract a substring using PowerShell
- Java String Split by “|”
- Convert String to double in Java
- TypeError: not all arguments converted during string formatting python
- Conversion from string to char – c++
- How to convert an int to string in C?
- Array to String PHP?
- How can I exclude one word with grep?
- What is `CString`?
- Java String new line
- Creating multiline strings in JavaScript
- Extract substring in Bash
- Regex not operator
- ‘str’ object does not support item assignment
- How to check if a String contains another String in a case insensitive manner in Java?
- How do I append one string to another in Python?
- Java split string to array [duplicate]
- How to convert a string to integer in C?
- String concatenation: concat() vs “+” operator
- How to compare strings in Bash