Ask Experts Questions for FREE Help !
Ask
    adalton's Avatar
    adalton Posts: 22, Reputation: 1
    New Member
     
    #1

    May 28, 2009, 03:55 PM
    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?
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    May 28, 2009, 05:19 PM

    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
    adalton's Avatar
    adalton Posts: 22, Reputation: 1
    New Member
     
    #3

    May 28, 2009, 06:19 PM

    Excellent. Thanks!

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Excel Macro [ 13 Answers ]

I have some code that loops through a row and a column and compares data. When it finds the values being equal it copies the columns the row is in and pastes it on another sheet along with the previous value of the column. For Each CCell In Range("C2:C65418") If Not IsEmpty(CCell.Value)...

Excel macro [ 4 Answers ]

I need to run a macro that opens excel so I can kick off "application.ontime" basically my macro should run without me having to start excel, just have the computer and outlook running. Is that possible?

Start excel with a macro [ 3 Answers ]

How can I start excel with a macro.

Recording a macro in Excel [ 2 Answers ]

Need a macro that will select the cell one place to the left, edit the content, hit enter, and then move to cell below where started and repeat to end of column (last cell with a value). Example: 123-456789 is format of cell to be edited - need to remove the hyphen. Someone had created it...


View more questions Search