Tracker
HOME    TRACKER    Excel

# Find The Longest String Including A Variable

## I have a database application which appends an "A" to the sequence number each time an entry is amended and then posts it as a new row in the database. This means there can be multiple entries with the same number but with different amount of "A"'s afterwards. e.g. Cell A6 contains seq no 1 Cell A7 contains seq no 2 - Seq no 1 is subsequently amended so... Cell A8 contains seq no 1A - 1A is subsequently amended so... Cell A9 contains seq no 1AA - and so on and so forth.......... What i am trying to achieve is a formula which will look at the record number which is required (i.e. 1) and will search for record 1 with the most number of "A"'s appended. This way the user will only be amending the most up to date record. The formula i have tried (but doesn't work) is: =INDEX(A6:A65536,MATCH(B2&MAX(LEN(A6:A65536)),A6:A65536,1),0) (B2 is the record the user wants to amend)

Related Forum Messages:
Find The Longest Run Of Zeros In A Column
I have a list of dates in column A (sequential from low to high).
I have corresponding rainfall data in column S.

I am trying to find the longest run of 0's in the rainfall data and return the start and end dates. It would be great if i could tell it (in cell C8) to find the longest run below this number.
ie: i say i want to find the longest run of numbers below 5.

Find Variable Size Number Within Text String
I have a spreadsheet with a couple of hundred rows on each tab that looks like this: A1: #1 PENROSE TIJUANA MAMA PCH 2620039190 665794 12.00 CT 1 Front 1 1 1. The only constant is the 10 digit number followed by the 6 digit number in the middle and I want to use it to parse the text string. I want the output to be everything prior to the 10 digit number in A1, the 10 digit number in B1, the 6 digit number in c1 and everything else in D1 and so on through the rows.

Including Column A String Into Input Box
I have a code of;

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set Target = Me.Range("c4:f100")
Dim iSold As Long, iColumn As Integer
Dim strTitle As String
If Intersect(ActiveCell, Target) Is Nothing Then Exit Sub
iColumn = ActiveCell.Column
Select Case iColumn
Case 3

An what i need to happen id the input box saying "Please enter quantity of (whatever is in cell A11) assuming i am clicking on E11

so in other words, in cell A11 it says "MONITOR", i need the input box to pop up and say "Please enter quantity of MONITOR "

Inputbox Value Can Be Compared To A String Variable Or A Numeric Variable At The Same Time
I am trying to develope a "goto" page macro where the page value maybe 1,34,7A, 256C etc. I am not clear on how an inputbox value can be compared to a string variable or a numeric variable at the same time. This is what I have done, but when the texboxvalue is "7A" it doesn't work.

String Variable To Call Defined Range Variable
Say you define a public range variable called Inputworksheet and you set it to refer to the worksheet called Inputworksheet. You have a separate string variable with the value Inputworksheet. How do you get this string variable value to call/control the range variable Inputworksheet?

I am getting an excel worksheet value from a lookup function that corresponds to the name of a VBA range variable. Once I have this worksheet value, I would like to use the range variable that has the same name as the worksheet value.

Find And Find Again - Object Variable Or With Block Variable Not Set
After doing a search, I need to ask an Excel 2003 question. I'm creating a tool to open three sparate workbooks. One is the driver and I need to use it to pull data from the second and then to place that data along with additional data into the third.

My driver data may consist of a single value or multiple values separated by semi-colons in a cell. A single value works fine. The first value in a multi-value condition works fine. the second find, however, gives me an object error. I'm using the " split" verb to separate the values. Here's my code. Have you any idea why the second find is throwing up this error when the first find works correctly?

varData = Split(strRef, ";", -1)
For J = 0 To UBound(varData)

varSrchVlu = Trim(varData(J))
' do the ARIS Exrtact matching
Workbooks(strManualFile).Activate
Workbooks(strARISExtract).Activate ' Activate ARIS Extract
Sheets("Processes").Cells(2, 1).Activate
Workbooks(strARISExtract).Sheets("Processes").Range("A2").Select
Workbooks(strARISExtract).Sheets("Processes").Columns("A:A").Select

Find Dates Macro: Object Variable With Block Variable Not Set
I found this nice little bit of code for a date range search in column A but it will not work. Apparently i have not set a variable or something.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim startDate As String
Dim stopDate As String
Dim startRow As Integer
Dim stopRow As Integer
startDate = InputBox("Enter the Start Date: (dd/mm/yyyy)")
If startDate = "" Then End
stopDate = InputBox("Enter the Stop Date: (dd/mm/yyyy)")
If stopDate = "" Then End
startDate = Format(startDate, "dd/mm/yyyy")
stopDate = Format(stopDate, "dd/mm/yyyy")
startRow = Worksheets("sheet1").Columns("A").Find(startDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
stopRow = Worksheets("sheet1").Columns("A").Find(stopDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
Worksheets("Sheet1").Range("A" & startRow & ":A" & stopRow).Select

End Sub

Find Method Code: Object Variable Or With Block Variable Not Set
I need my program to:
- find the cell containing the string "Datum/Tid"
- record the column and the row of the found cell in two variables lCol and lRow

Here is my

Sub test()

Dim rFoundCell As Range
Dim lRow As Long
Dim lCol As Long

'Find method of VBA
Set rFoundCell = Range("A1")
Set rFoundCell = Worksheets("Sheet1").Range("A1:Z50").Find(What:="Datum/Tid", After:=rFoundCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

'for anyof the two lines down I get the message "object variable OR block variable not set"

lRow = rFoundCell.Row
lCol = rFoundCell.Column

End Sub

Find Method: Object Variable Or With Block Variable Not Set
I have a spreadsheet form with all kind of values and what I want to do is to find a data in a worksheet named "Config" based on the spreadsheet activecell value. With the find row adress I return data of another column but same row (in the worksheet) in two diferent label captions. If the spreadsheet activecell value it was found in the worksheet everything is ok but if the value is not found I'm getting the message "Object variable or with block variable not set"....

Count Longest Run Of Numbers Above Mean
I'm attempting to summarise several hundred control charts.

One thing I'd like to do is be able to put in a formula to count the maximum number of successive entries that are all the same side of the mean.

Another related thing is to be able to count the longest run where successive values are the same.

IF.. Contains...then: Search Through The Text String In That Cell And Find A Certain Word, Find And Retrn A Value
I am having trouble getting my IF statement to test if the cell contains the text "sale" return "X" if not "Y". I need it to search through the text string in that cell and find a certain word, and if it finds that word, retrn a value. I am really having difficulty with is what symbol or function do I use for the logical test? (i.e. =, <>, MATCH, INDEX?)

Getting A Loop Including "find" To End When It Gets Back To The First Result
I am wondering why the loop at the end of this macro loops endlessly.

Count Longest Run Of Contiguous Zeros
I am trying to figure out how to create a formula or VBA to count how many contiguous 0's there are in a specific row...and then drag this formula down many rows..for example - if a row of data contains 1,3,0,0,0,4,5,0,0,0,0,0,0,0,5,3,1,0 I want the result to be 7, because 7 is the longest streak of contiguous 0's.

Extend Range To Longest Column
I had asked about automatically naming regions and this is an extension of that post because it's closed. The code we ended up with to name the region is:
Dim sNm As String, sRT As String

If Intersect(Target, Rows(1)) Is Nothing Then Exit Sub '------------------->
If Target.Count > 1 Then Exit Sub '---------------------------------------->

sNm = Replace(Trim(Target), " ", "_")
sRT = "=offset(" _
& ", 1, 0, counta(" _
& Cells(2, Target.Column).Resize(Rows.Count - Target.Row).Address & ") )"

My problem now is that I need to have the regions be the length of the longest column. I've tried using a few different ways using the worksheet range but I can't seem to get it to work.

First And Last Date In The Longest Continued Range
I am looking for a formula that returns the date of the first and last value in the longest continued range.

In the example:

CD30CLA3101/02/200833201/03/20086
3301/04/200853401/05/20083501/06/200863601/07/200823701/08/2008

The two formula should return the two dates in blue.

Indicate That A Variable Is String
I understand that a everything is already considered to be string, but how would I phrase this?

If txtBolow = (a statement which indicates the textbox is full) Then

txtBolow. SetFocus
txtBolow. SelStart = 0
txtBolow. selLenght = Len(txtBolow)

If txLowl = ("") Then
txtLowl. SetFocus
txtLowl. SelStart = 0
txtLowl. selLenght = Len(txtBolow)

What would I use to indicate that the user has completed the data in the textboxes, and the old data is highlighted to make way for the new?

How To Get Set Of Chars From A String To A Variable ..
CALIB/SENS,S(S5a90b-90),FA(CAL_15)

This one has two sets of quotes, with the information from the noted post I can retrieve the string "S5a09b-90", now that I have a double set of brackets "( )" how do I get the value for the second set of brackets, "CAL_15"?

In the quoted string, CALIB/SENS,S, is constant. The first set of brackets are constant (string length is not), the second set of brackets are constant (string length is not).

Parsing A String Variable
It's been a long time, but I use to parse a string in C.
How do you strip off the long directory path of a string to just the filename and extension?

String Example:
S:2006 jobs602f EID Bass Lake Recycle BPSConstructionSubmittal Review16940-Instrumentation602f-16940-01.rev.doc

Wanted result:
0602f-16940-01.rev.doc

Set A Workbook Variable As A String
I have a string variable contacting a file.

I want to set a workbook variable to this file, WITHOUT actually opening it!

ie:
DIM wb as Workbook
DIM filenm as String

filenm = "C: empdata.xls"
set workbook = filenm
============================================

So I know this won't work, but is there anyway around it? (bearing in mind I don't want to open the file!

Use String-Variable In Formula
if it is possible, to use a string variable in a Formula via VBA.

For example: ActiveCell.Formula = "=SUM(Sheet3!strVariable)"

Of course the code is not working that way. The Variable has the following structer: CellAdress;CellAdress;CellAdress... so it would perfectly fit into the formula-syntax.

Is there any possible way to do that? The reason behind it is, that I have to deal with a flexible range and I want to process this range with a formula. Actually the range is flexible, because of different filters and I only wanna count all numbers in the unhidden rows.

My varibale would then contain all celladresses, for the visible cells.

So in a nutshell: is it possible to somehow use a varible in a formula?

Using A String Variable For Sheet Name
I am trying to use a variable for the name in the Sheets command so that I can put in the names of the CSV file that I have captured in a variable. Here is the macro that I recorded using Excel 2007:

Get Set Of Chars From A String To A Variable
I believe I should use the INSTR function, but I simply dont understand its use very well. I have a string in a cell, "MEAS/SPHERE,F(QUA_1),5", the characters I need start at the "(" and end at the closing ")", ref: (QUA_1). The start and end will always be the same, the length of characters and the spelling of characters be anything. Thus, QUA_1 can be CAL_1, CAL_2, SOMEOTHERTEXT_1 or 187bgo_199, etc, always enclosed in "( )". I wish to place the characters and the closing "( )" into a variable as a string.

Using A String Variable In Formula
Just a quick question, is it possible to use a string variable in a Excel formula (in VBA)? Im trying to do the following in VBA

mortgageSchedName = acName & " Schedule"
Range("B6").FormulaR1C1 = "=mortgageSchedName!RC[254])"

the above results in an error because there is no such sheet as "mortgageSchedName", but I want it to access the value of that string variable.

Split String Variable And Use Some In Filename
I have a filname called ex: "Statusreport xxyyzz.xls"

I'm only interested to put xxyyzz in a variable and reuse it for saving another workbook.

How can I use the different string functions for this. The word "Statusreport" is used for apporx 20 different workbooks.

Remove Some Chars From End Of String Variable
I want to remove varying amounts of periods that appear at the end of my strings. For instance, ABCEDFGH......., DEFGH.., FG.... etc. Do I have to test each char to see if it's a period, and then use that count of chars to LEFT out the string that I want? Or is there an easier, quicker way to do this?

Pass Filename To String Variable
Have a file lets say is named

sample.xls

Does anyone know how to retrieve the name of the file in VB?

just the name and put it in a string?

Removing Characters From A String Variable
Let us assume x and y are strings. Now let us make x equal to a small sentence (ie. full of words and spaces). I now need to somehow make y equal to x, but with the last word removed. I need to do this in VBA.

Converting A String To A Worksheet Variable
I have a userform that reads in a list of names into a combobox. When you choose a name from the combobox it then shows the that persons details from a sheet containing all the names.

I have some text boxes that allows the data to be modified and returns it to the sheet which works fine. What i also want it to do it put the data from the form into a sheet for that individual. For example the name of Ford would go into the Ford worksheet.

How do i read in the value from the combobox on the worksheet and use it as a variable to use in my code. For example

Sheets(Value from the combobox).Cells(NoOfRows, 3).Value = Me.TextBoxChangePosistion.Value

*NoOfROws is the variable to find a blank row

Variant Variable From List Box To A String
I have a multiple select list box which I capture the selected items by using ListBox1. List

I want to use the 'selection' to build up a string that will form a document name I want to add to an email as an attachment (all being done from Excel), however I get a type mis-match error as the ListBox1.List output is a variant.

So I'm aiming to have something like MyFile = firstpartoffilename & ListBox1.List & "*.doc"

Do I need to somehow convert the variant variable or are there some other clever tricks I can use to create my document name.

Extracting Text From A String With Variable Length
Hey I got a long String like this "[...] increase of x.xx% [...]".

I am trying to extract only the percentage number which can be of variable length, so maybe 900.99% or 9.99%.

I tried this formula:
=MID(G14,SEARCH("%",G14)-5,5)
but this one doesnt bring the right results as the percentage figure is often not exactly 5 characters long.

String Parsing With Variable Length Strings
I am trying to split up a cell into numbers and charachters and place them in
separate columns, but the lenght of the number part varies as does the
content of the character part.

For example, one cell could be 5#, 10Tins, 4 lb, 100Pcs, etc.
I would like to be able to pull out the #, Tins, lb, and Pcs in to their
own column.

I have found this formula:
=LEFT(A1,FIND("-",A1,1)-1)

but it assumes some level of consistency, the "-" in the cell.

Append Numeric Portion Of String To Variable
How would I be able to assign a number portion of a variable string to another string variable. For example I have the following string:

AOSXLS_356-NewInfo

I just want the 356 assigned to a string variable.

only the first 7 characters won't change. The number part could be 2 or 4 digits, and the NewInfo portion could be anything.

Extract Number Of Variable Length From Text String
Imagine that I have this list of thousands of customers, who are listed in column B in the format "customer no+space+customer name".

Now I want to extract ONLY the customer no from the text string in column B and insert it as number value in column A on the same row.

Would have been easy with "Left" command, but as the customer numbers have variable length, I have a problem.

Insert Column Macro Based Variable String Letter
I'm working on some code that's part of a userform. To illustrate what I need, I will give an example. A column letter, 'J' for example, is stored in colNum.Value taken from the userform. I need both a column inserted before column J, and data entered into that new column in row 2 (thus J2, which would now be blank).

VBA; Find String And Copy
I would like to call up a find box, then be able to search several worksheets for a string, to copy and paste the related row to a new worksheet.

I've gotten as far as being able to search for a string and get the row pasted, as long as the string is defined in my macro. Is there a way though to be able to call up a find box first though, and search for the input variable? (alternatively, I can only imagine a separate piece of code for each variable, of which there are many, and I am actually trying to save time.

Find Last Row With Text String
The following line finds last "non-blank" row in a column. I have a column that has formulas in 10000 rows. Most of the time only first 7000 rows will have data, other cells below will have "". I need to find the last row with real data, not "".

Is there a way to add a condition or check to the following line?

Find Numeric Value At End Of String
say I have a string that looks like this

C:Documents and Settingsme[test 2-2006.xls]Sheet1

I want to extract the DATE prior to .xls. I can get to this:
C:Documents and Settingsme[test 2-2006

It is possible that the filename would have numbers in it prior to the date.

I'm trying to figure out a way to get to the last SPACE in the string.

Find A String And Bold The Row
I am using ctrl+f to find a string that may or may not be in a worksheet.

If it is found, i need to bold the row.

If it is not found, i need to go on to the next instruction in the macro.

I just don't know quite how to combine the If/Then with Find.

Find Text In A String
I have the following string of text and want to take out certain parts of it. Assume the string is in cell A1.

In cell B1 I want "Company ABC DEF"
In cell C1 I want "10.50%"
In cell D1 I want "12/13/2014"

String:
Company ABC DEF (USD) 10.50% 12/13/2014

how the MID formulas work (as a bonus)? I used =MID(A1,FIND(")",A1,1)+2,45) and it returns "10.50% 12/13/2014".

So I see that that formula says start from 1 character after ")", count 2 over, and then put in the next 45 characters. How do I do an in between amount, and how do I just have it come from the LEFT but stop when it finds " ("

1) Find strings "CA", "Ca", "ca", "California", "california", "cali", "Cali" in Column F

2) If the string is found, then record the Real value at Column D of that row in Column I

3) Continue this until there are no more strings in Column F

4) Add the values recorded in Column I and display the final value at the bottom of the list.

Find Value In String Using VBA Macro []
I need to check a certain value in a string

1.VOX-20-APPL-01
2.VOX-20-APPL-01-AP01
3.VOX-20-APPL-01-AP02
4.VOX30-APL
5.VOX30-APS-AP01

In the list over I want to find nr 2 and 3. Using Instr sorting for 'ap' gives me all the list. How could I use string functions in a VBA macro.

Find Max Of String According To Criteria
I want to find out the max of (Property No) which is String and Number together, according the (Location), How it is possible?
for further info see the example...

Web And Find Text String...
I have this page in html. How to find the value 1 and 4 in:

<td WIDTH="25%" ALIGN="center"><font style="font-family: Verdana,
Arial, Helvetica, sans-serif; font-size: 10px; font-weight:
bold">&nbsp;Pagine&nbsp;1&nbsp;di&nbsp;4&nbsp;</font></td>

and to find the value 308: <td align="center" colspan="11" class="INFO">Totale fidi individuati:308<br></td>. after store the value founded in var_1, var_4 and var_308. NOTE: in this case the value are 1, 4 and 308 but the contet of tag the value can change because the page is dinamic, in other case find the value after:

font-weight:bold">&nbsp;Pagine&nbsp;now is 1
font-weight:bold">&nbsp;Pagine&nbsp;1&nbsp;di&nbsp;now is 4
<td align="center" colspan="11" class="INFO">Totale fidi individuati:now is 308

Find Number Within A Text String Using VBA
I have a list of English game results with the score and the soccers of the game.

E.g. : [Steinsson 34, Davies 41, Elmander 46; Fuller 91]

As you can see in the excel, what Im trying to do is to find the time i.e which is the numbers in the field and display them seperately onto the cells beside. So what i need is to Find and extract these numbers 34,41,46,91 and paste them just beside cell on the list.

I can use formula but i can only display 1 number, so i think this might require a VBA script.Thanks in advance guys..

Find Specific String In Cell
I have at database which i want to search in... The problem is that i wanted to search in specific cells, or ranges. So i made a for loop searching for words in one range.. But it doesn't work.

For i = 0 To antal - 1 Step 1
Worksheets("Søg").Select
If Range("B5") = "X" Then
Sheets("Database").Select
c = InStr(1, Range("B" & 2 + anRow * i), sgbygsag, 1)
Sheets("Søg").Select
Range("A1") = c
End If
Next

anRow is the delimiter between to databases. And sgbygsag is the string i am searching for, i have made sure that this really is a string. No matter what I do this code sets Range("A1") to "0".

Find Text String Value Between Quotes
Formulae Solution prefered if possible--

Is it possible to extract the two text strings between the quotes, placing them in Col. C & D respectively, e.g.
Application.WorksheetFunction.Substitute(c.Formula, " ANTI ", " ANTI-HERO ")
Application.WorksheetFunction.Substitute(c.Formula, "SEC9", "SECTOR 9")
Application.WorksheetFunction.Substitute(c.Formula, "LNGBRDC", "LONGBOARD COMPLETE")

--Col. C---------------Col.D
Anti------------------Anti-Hero
SEC9--------------- SECTOR 9
LNGBRDC---------- LONGBOARD COMPLETE

There are three types of scenarios-
1) Values enclosed in quotes that begin and end w/ spaces:
Application.WorksheetFunction.Substitute(c.Formula, " ANTI ", " ANTI-HERO ")

2) Values enclosed in quotes that does not contain a leading space or trailing space:
Application.WorksheetFunction.Substitute(c.Formula, "SEC9", "SECTOR 9")

3) Values enclosed in quotes that have a space between itself:
Application.WorksheetFunction.Substitute(c.Formula, "LNGBRDC", "LONGBOARD COMPLETE")

Find Text String In A Value Instead Of In A Formula
What formula can I use to search a range of cell values for a specific text string? My method is searching formulas instead, which is not what I want.

Background: I am developing a little test script for a project and I want to include some automatic validations to help make the job of the testers easier.

What I have set up so far:

1. Testers input numbers into specific fields M8 through M20.

2. Fields N8 through N20 automatically check fields M8 through M20 and compare those with what is contained in a range of hidden cells I set up in advance. A formula ensures that it reports "correct" or "incorrect" on a field-by-field basis, based on the comparison.

3. Cell O8 searches for the text string "incorrect" in cells N8 through N20. If that text string appears in any one of the cell values (not formulas), then O8 directs the tester to test again. If the text string "incorrect" does not appear, then cell O8 reports that the test was successful, and the tester can proceed to the next test (exact same setup repeats).

My only problem is in the formula used for the last step. I have tried a few different formulas I know in cell 08, but none are giving me the results I'm looking for. The closest I have come is a successful search and validation based on the string being in the formula instead of in the value of the given cell.

Macro Find Text String
I have a workbook which contains 12 sheets, is it possible write a macro which will search for a text string which could be on any of the 12 sheets

Find The First 3 Characters Of A Text String
How I can change this formula to find the first 3 characters of a text string?

Instead of using numbers in column A, it will be Names, I need the user to enter only the first 3 characters of the name and then display the results, (Meaning that all others irrelaavnt rows will be hidden.

Sub myHidingRoutine()
Dim foundCell As Range

With ThisWorkbook.Sheets("Sheet1")
Set foundCell = .Range("a:a").Find(What:=.Range("a2").Value, After:=.Range("a2"), _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

Find Text String In Web Query
I want to find the number within this webpage and report it to a Cell in excel....