3
Some Excel Tricks Step 1: Select a blank cell; in this case, we select the Cell D2. Step 2: Paste the formula of =INDEX(A1:A20,MATCH(MIN(ABS(A1:A20- D1)),ABS(A1:A20-D1),0)) into the cell D2. A1: A20: The range that you want to find the specific value. D1: The searching value that you want to be compared with. Step 3: Press the Ctrl + Shift + Enter keys together to apply the formula. Then it displays the closest value to the given searching value. See the following screenshot: Macro code for subscript or superscript Sub Super_Sub() Dim NumSub Dim NumSuper Dim SubL Dim SubR Dim SuperL Dim SuperR Dim CheckSub Dim CounterSub Dim CheckSuper Dim CounterSuper Dim Cell '

some excel tricks.docx

Embed Size (px)

DESCRIPTION

some excel tricks

Citation preview

Page 1: some excel tricks.docx

Some Excel Tricks

Step 1: Select a blank cell; in this case, we select the Cell D2.

Step 2: Paste the formula of =INDEX(A1:A20,MATCH(MIN(ABS(A1:A20-D1)),ABS(A1:A20-D1),0)) into

the cell D2.

A1: A20: The range that you want to find the specific value.

D1: The searching value that you want to be compared with.

Step 3: Press the Ctrl + Shift + Enter keys together to apply the formula. Then it displays the closest

value to the given searching value. See the following screenshot:

Macro code for subscript or superscript

Sub Super_Sub()Dim NumSubDim NumSuperDim SubLDim SubRDim SuperLDim SuperRDim CheckSubDim CounterSubDim CheckSuperDim CounterSuperDim Cell'CheckSub = TrueCounterSub = 0CheckSuper = TrueCounterSuper = 0Cell = ActiveCell

Page 2: some excel tricks.docx

'NumSub = Len(Cell) - Len(Application.WorksheetFunction.Substitute(Cell, "[", ""))NumSuper = Len(Cell) - Len(Application.WorksheetFunction.Substitute(Cell, "{", ""))'If Len(Cell) = 0 Then Exit SubIf IsError(Application.Find("[", ActiveCell, 1)) = False ThenDo    Do While CounterSub <= 1000        SubL = Application.Find("[", ActiveCell, 1)        SubR = Application.Find("]", ActiveCell, 1)        ActiveCell.Characters(SubL, 1).Delete        ActiveCell.Characters(SubR - 1, 1).Delete        ActiveCell.Characters(SubL, SubR - SubL - 1).Font.Subscript = True        CounterSub = CounterSub + 1        If CounterSub = NumSub Then            CheckSub = False            Exit Do        End If    LoopLoop Until CheckSub = FalseEnd If''If IsError(Application.Find("{", ActiveCell, 1)) = False ThenDo    Do While CounterSuper <= 1000        SuperL = Application.Find("{", ActiveCell, 1)        SuperR = Application.Find("}", ActiveCell, 1)        ActiveCell.Characters(SuperL, 1).Delete        ActiveCell.Characters(SuperR - 1, 1).Delete        ActiveCell.Characters(SuperL, SuperR - SuperL - 1).Font.Superscript = True        CounterSuper = CounterSuper + 1        If CounterSuper = NumSuper Then            CheckSuper = False            Exit Do        End If    LoopLoop Until CheckSuper = FalseEnd If'End Sub