?
Solved

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

Posted on 2016-10-08
6
Medium Priority
?
56 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

719 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