Have letters BN need formula to subtract by one = BM

Dojorgen

Board Regular
Joined
Mar 1, 2018
Messages
59
Hey guys quick question could not seem to find online.

I have variable letters for example BN and would like a formula that would subtract that value by one so it displays BM.

Any suggestions would be much appreciative.:):)
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Probably a simpler way than this


Excel 2013/2016
AB
1BNBM
Cover
Cell Formulas
RangeFormula
B1=TRIM(LEFT(SUBSTITUTE(ADDRESS(1,COLUMN(INDIRECT(A1&"1"))-1,2),"$",REPT(" ",100)),100))
 
Upvote 0
A minor simplification and a UDF alternative:

A​
B​
C​
1​
Column
Prior Col
2​
BNBMB2: =SUBSTITUTE(ADDRESS(1, COLUMN(INDIRECT(A2 & 1)) - 1, 4), 1,)
3​
BNBMB3: =ColLtr(ColNum(A3) - 1)
4​
ABCDEFGABCDEFF

Code:
Function ColLtr(ByVal iCol As Long) As String
    ' shg 2012
    ' Good for any positive Long
    If iCol > 0 Then ColLtr = ColLtr((iCol - 1) \ 26) & Chr(65 + (iCol - 1) Mod 26)
End Function

Function ColNum(ByVal sCol As String) As Long
    ' shg 2012
    ' Good to column FXSHRXW (2147483647)
    If Len(sCol) > 0 And _
       (Len(sCol) < 7 Or UCase(sCol) <= "FXSHRXW") Then
        ColNum = Asc(UCase(Right(sCol, 1))) - 64 _
                 + 26 * ColNum(Left(sCol, Len(sCol) - 1))
    End If
End Function
 
Upvote 0
Code:
=SUBSTITUTE(SUBSTITUTE(CELL("address",OFFSET(INDIRECT(A1&"1"),0,-1)),"$",""),"1","")
It appends "1" to the column letter to get a valid cell address, then it uses INDIRECT to get that cell, then OFFSET to refer to one column left (-1), then CELL/"address" to get that cell's address string. Since the string has dollar signs and a 1, it strips those with SUBSTITUTES.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top