finding a column by searching

  • Thread starter Thread starter monika
  • Start date Start date
M

monika

HI ...

I am doing a search for a word "Location" in the heading in a worksheet. My
purpose if to find that column which contain s that string....and then I
have to insert a column exactly next to it.

hw can i achieve this..thru vba?

thanks a plenty
Monika
 
Hi Monika,

What a silly question, can it be done through VBA. Of course it can <vbg>.

Here's the code

Dim oFind As Range

Set oFind = Cells.Find("Location")
If Not oFind Is Nothing Then
Columns(oFind.Column + 1).Insert
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
wow thanks Bob ...it works like wonders...!

i am really sorry to bother with silly questions...i haven't done much
coding in vba.
and also i am used to working with macros...that's how i take ideas for
coding. the solutions posted by expert people in Microsoft group are really
neat and different and elegant.

hence this approach of a beginner
 
Monika,

It is not a silly question, that was my attempt at humour, hence the <vbg>
(very big grin) at the end. I was just alluding to VBA being able to do
(almost) anything (not always the best thing to do, sometimes a rep-design
is simple, more effective, and more elegant).

Bob
 
Back
Top