Tuesday, March 26, 2013

How To Search in a Dynamic Column in Excel

Excel VBA Macro To Find a Dynamic Column Name
Sub Dynamic_Column_Search()
Dim Col_Search As String
Dim TargetColumn As Range

Col_Search = "Consol_Data" 'Dynamic Column Name That you want Search or Find

Set TargetColumn = ActiveSheet.Rows(1).Find(What:=Col_Search, LookIn:=xlValues, _

    LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)

If Not TargetColumn Is Nothing Then

        MsgBox "Target Column Found At  " & TargetColumn.Address & _
        " and the Targe Column Number is " & TargetColumn.Column
Else:
MsgBox "TargetColumn Not Found"
End If
End Sub

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. If you wish, please share your genuine Feedback or comments only related to this Blog Posts. It is my humble request that, please do not post any Spam comments or Advertising kind of comments, which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose we have a sample Sales data, which is stored with Monthly Snapsh...

Popular Posts from this Blog