Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   Excel Macro Value Comparison (https://www.askmehelpdesk.com/showthread.php?t=358913)

  • May 28, 2009, 03:55 PM
    adalton
    Excel Macro Value Comparison
    I am creating a function in my macro to check to see if the value of a cell's 2nd digit is equivalent to some number. Say check if it is a 2 so 1234, 4244, 5255, x2xx all would work, then if so I want to insert a column there. Is this possible?
  • May 28, 2009, 05:19 PM
    JBeaucaire

    This little macro will evaluate the ACTIVECELL. You can adapt this for your uses, I imagine:
    Code:

    Sub CheckDigit()
    Dim MyVal As Boolean
        MyVal = Mid(ActiveCell, 2, 1) = 2
        If MyVal = True Then ActiveCell.EntireColumn.Insert (xlShiftToRight)
    End Sub

  • May 28, 2009, 06:19 PM
    adalton

    Excellent. Thanks!

  • All times are GMT -7. The time now is 05:13 AM.