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
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. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.