Convert column to text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I want to convert a column with "SSN" title in text but I don't know where
the column is located. The programation below gives me the first column wich
contains SSN title. Does anyone know how to find an exact match of the SSN
title ?
Thanks!
} Set rng = wks.Rows(1).Find(What:="SSN")
} If Not rng Is Nothing Then rng.EntireColumn.TextToColumns Cells(1,
rng.Column)
 
Find takes a number of arguments. Add this argument and it will require an
exact match...

Set rng = wks.Rows(1).Find(What:="SSN", LookAt:=xlWhole)
 
Record a macro when you do the .find manually. You'll see one of the options is
to look at the whole cell.

LookAt:=xlWhole

I think you'll find it better to specify all the parms that you can. Excel/VBA
will remember the last settings used--no matter if the user did it or your code
did it.

with wks.rows(1)
set rng = .Find(What:="SSN", _
After:=.cells(.cells.count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True)


I specified match case and whole cell.
 

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

Back
Top