Kamis, 17 Mei 2012

Re: [ExcelVBA] need to find a specific column in a table

 

This works :-

Sub test()
Dim i As Integer
    For i = 1 To 30 'Total no. of columns
        If Cells(2, i).Value Like "MAX*" Or Cells(2, i).Value Like "DS*" Then
            MsgBox "Column " & i & " contains Part Number"
            Exit For
        End If
    Next i
End Sub

How likely is it that any other column might contain "MAX" or  "DS" ? If high then you will have to examine more rows.

Regards 

Del +++

>________________________________
> From: Purushottam Kumar <purushottam.jsr@gmail.com>
>To: ExcelVBA@yahoogroups.com
>Sent: Thursday, 17 May 2012, 8:43
>Subject: Re: [ExcelVBA] need to find a specific column in a table
>
>

>Hi,
>
>i have not tested this code but hope it may works.
>
>sub test()
>dim i as integer
>for i= 1 to 30 'Total no. of columns
>if cells(2,i).value="MAX*" or cells(2,i).value="DS*" then
>msgbox columns(i) & " contains Part Number"
>end if
>next i
>end sub
>
>it search 2nd row & if found part no then msgbox displays.
>
>On Thu, May 17, 2012 at 10:53 AM, sunnywulf
><wolfram.schneider@maxim-ic.com>wrote:
>
>> **
>>
>>
>> I have an Excel table where one of the columns contains our company's part
>> number. This part number has the prefix MAX or DS followed by a number that
>> is at least 3 digits long (examples: MAX123 or DS987).
>>
>> The table dimensions can be several hundred rows and up to 30 columns. The
>> column with the part number has no fixed location and can be anywhere.
>>
>> How can I determine in VBA the number of the column that contains the Part
>> Number?
>>
>> I did not find anything wen googling this question. I hope somebody can
>> help me with this challenge.
>> Thank you for your replies,
>> sunnywulf
>>
>>
>>
>
>--
>
>[Non-text portions of this message have been removed]
>
>
>
>
>

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar