Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to pull text from inside a formula in Excel 2010?

Posted on 2016-10-08
6
Medium Priority
?
59 Views
Last Modified: 2016-10-08
I have some formulas that are on the wrong rows.
For example, the formula is on row 782 should say
=IF('MS Only Alt & Kept Commands'!M782<>'MS Only Alt & Kept Commands'!J782,'MS Only Alt & Kept Commands'!$J782,"")
but actually says
=IF('MS Only Alt & Kept Commands'!M781<>'MS Only Alt & Kept Commands'!J781,'MS Only Alt & Kept Commands'!$J781,"")

Is there a way to pull 781 out of the formula and show it.?
0
Comment
Question by:Alex Campbell
  • 2
  • 2
  • 2
6 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41835291
You can do such a thing with the help of VBA.
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 41835294
I don't know what you mean by "show it" but this will update the formulas on row 782.

Sub ReplaceRowNumber()
Dim cel As Range
With ActiveSheet.Rows(782)
    For Each cel In .Cells
        cel.Formula = Replace(cel.Formula, "781", "782")
    Next
End With
End Sub

Open in new window

0
 
LVL 1

Author Comment

by:Alex Campbell
ID: 41835317
It would show in a separate cell.
I want to do that since there could be a number of rows that are mismatched.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 total points
ID: 41835319
This formula

=chkrowfrmla("B781")

with this code

Function chkrowfrmla(frmla As Range)
If InStr(frmla.Formula, frmla.Row) > 0 Then chkrowfrmla = "" Else chkrowfrmla = "Mismatch"
End Function

will return "Mismatch" wherever the row number is not found in the formula.

This code will not catch if the row is 24 but the formula says 243
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 41835348
I think this update to Syed's code solves the problem he refers to. (Edit: changed code to remove "M")

Function chkrowfrmla(frmla As Range)

Dim strParts() As String
Dim strTemp As String
strTemp = Replace(frmla.Formula, "<", "!")
strParts = Split(strTemp, "!")
If UBound(strParts) < 1 Then
    chkrowfrmla = ""
    Exit Function
End If
strTemp = Replace(strParts(1), "M", "")
If strTemp = frmla.Row Then
    chkrowfrmla = ""
Else
    chkrowfrmla = "Mismatch"
End If
End Function

Open in new window

0
 
LVL 1

Author Closing Comment

by:Alex Campbell
ID: 41835358
This works just fine. Thanks
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question