Find Column number based on searching of string

With the answer to the previous question:
I now need to determine the column number by finding the text in any cell on the active worksheet.
text = "Customer Mfgnumber Search"

previous question:
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_26938598.html#a35337484
previous answer:

If Cells(1, target.column) = "Customer Mfgnumber Search" then
' rest of your code

This will only look in row 1  so...I need to

Find the value in any cell on the workbook and then designate that column as the target column number


Thanks
fordraiders
LVL 3
FordraidersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sshah254Commented:
Just use two nested for loops

for longCurrentRow = 1 to 1000 'or whatever number you choose ... typically this should be extracted from ActiveRegion
   for longCurrentColumn = 1 to 1000 'or whatever number you choose
      if Cell(longCurrentRow, longCurrentColumn) = 'Customer Mfgnumber Search' then
          'rest of your code
      end if
   next
next

Ss

0
cyberkiwiCommented:
Dim found As Range
Set found = Cells.Find("Customer Mfgnumber Search")
If found is nothing then
   column = 0 ' ?? not found
Else
   column = found.Column
End If
0
FordraidersAuthor Commented:
So either one of these answers will give the column number where the value was found ?
cyberkiwi ?
Else
   column = found.Column    <----- here
End If
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

FordraidersAuthor Commented:
option explicit

how to define column ?

just to make sure

0
FordraidersAuthor Commented:
cyberkiwi,
The reason I'm asking I need to pass the Column to a target intersect

Dim Result As String
   Set targ = Intersect(target, [C:C])   <---- HERE

what ever the column is,  that the value was found, I need to know it for this part in the code..
("Customer Mfgnumber Search")

I need to tranlate that column Number to a column Letter..?

Thanks
fordraiders


0
cyberkiwiCommented:
What do you do when it is not found?  Assuming it is found...

Dim found As Range
Set found = Cells.Find("Customer Mfgnumber Search") ' found is a Range object

Dim Result As String
If Not found is nothing then
    Set targ = Intersect(target, found.EntireColumn) '  <---- HERE
Else
    ' ?? what to do here
End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FordraidersAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.