Merging Match and Split Formulas

HGDantes

New Member
Joined
Feb 10, 2023
Messages
16
Office Version
  1. 2019
Platform
  1. Windows
Hello
Do you think that would be possible to merge both formulas/functions in order to obtain my ColumnLetter value ? If so, what would be the proper syntax?

VBA Code:
Dim ColumnNumber As Long 
Dim ColumnLetter As String 
ColumnNumber = WorksheetFunction.Match("Column Name", Rows("1:1"), 0) 
ColumnLetter = Split(Cells(1, ColumnNumber).Address, "$")(1)


Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Can you explain, with words, what you are trying to do?
 
Upvote 0
Sure.
I want to search an excel sheet for specific header names and put the letter of the column in a Variable.
With the Match Function, I'm able to retrieve the numerical value of the column.
Then with the Split I'm able to get the letter of the column from it's numerical value.
I would like to be able to get the result with a single operation.
 
Upvote 0
I thought so, just wanted to make sure.

VBA Code:
Dim ColumnLetter As String
ColumnLetter = Split(Cells(1, WorksheetFunction.Match("Column Name", Rows("1:1"), 0)).Address, "$")(1)
 
Upvote 1
Welcome to the MrExcel board!

Since you are using vba, I would be inclined to stick to features that are naturally available there rather than reverting to worksheet functions. Perhaps ..

VBA Code:
Dim ColumnLetter As String

ColumnLetter = Split(Rows(1).Find(What:="Column Name", LookAt:=xlWhole, MatchCase:=False).Address, "$")(1)
 
Upvote 1
Solution
Welcome to the MrExcel board!

Since you are using vba, I would be inclined to stick to features that are naturally available there rather than reverting to worksheet functions. Perhaps ..

VBA Code:
Dim ColumnLetter As String

ColumnLetter = Split(Rows(1).Find(What:="Column Name", LookAt:=xlWhole, MatchCase:=False).Address, "$")(1)
Super Thanks A lot. It's working perfectly
 
Upvote 0

Forum statistics

Threads
1,224,743
Messages
6,180,687
Members
452,994
Latest member
Janick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top