Solved

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

Posted on 2016-10-08
6
31 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:Alex972
  • 2
  • 2
  • 2
6 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
You can do such a thing with the help of VBA.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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
 

Author Comment

by:Alex972
Comment Utility
It would show in a separate cell.
I want to do that since there could be a number of rows that are mismatched.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
Comment Utility
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 45

Expert Comment

by:Martin Liss
Comment Utility
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
 

Author Closing Comment

by:Alex972
Comment Utility
This works just fine. Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
My experience with Windows 10 over a one year period and suggestions for smooth operation
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

728 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now