Using "Equiv" excel fonction in vba

A

Alex St-Pierre

Hi,
My goal is to convert to a text a specific column which contain title "SSN".
If the column "A" is SSN column, I could use:
Columns("A:A").TextToColumns Destination:=Range("A1") works if the column
"A" is SSN. Since, I don't know what is the column, I would like to say:
1- What is the column which contain "SSN" title on line 2 (like
Application.Equiv("SSN",Range(A2:IV2),False)
2- Convert this column number in text (Example: convert column "4" to "D"
3- After that, I could use fonction Columns("D:D").TextToColumns
Destination:=Range("D1") with D variable.

If somebody have a simpler solution, plz, let me know :)
Thank you,
-
Alex St-Pierre
 
J

Jim Thomlinson

Text to columns takes arguments and I don't know what they would be as I
don't know your data. That being said you should be able to fill that part
in... Try this code...

Sub ConvertToColumns()
Dim rng As Range
Dim wks As Worksheet

Set wks = ActiveSheet
Set rng = wks.Rows(2).Find(What:="SSN")
If Not rng Is Nothing Then
rng.EntireColumn.TextToColumns Cells(1, rng.Column), ???, ???
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top