+ Reply to Thread
Results 1 to 26 of 26

If statement check

Hybrid View

Royalmathmtcs If statement check 12-03-2008, 12:35 PM
Leith Ross Hello Royalmathmtcs, ... 12-03-2008, 12:42 PM
Royalmathmtcs Thanks for the reply Leith, I... 12-03-2008, 12:56 PM
Leith Ross Hello Royalmathmtcs, Will... 12-03-2008, 01:02 PM
Krishnakumar Hi, Here is a sample. Work... 12-03-2008, 01:16 PM
Royalmathmtcs That looks like it might... 12-03-2008, 01:56 PM
Royalmathmtcs Nevermind about finding the... 12-03-2008, 02:06 PM
Royalmathmtcs I added a few more arrays and... 12-03-2008, 02:35 PM
Royalmathmtcs I posted an small example of... 12-03-2008, 01:12 PM
Royalmathmtcs Krishnakumar, I really... 12-04-2008, 02:47 PM
Royalmathmtcs Ok, I figured it out...The... 12-04-2008, 03:07 PM
Leith Ross Hello Royalmathmtcs, This... 12-04-2008, 03:34 PM
Royalmathmtcs Hi Leith, This version... 12-04-2008, 06:39 PM
Leith Ross Hello Royalmathmtcs, You... 12-04-2008, 07:02 PM
Leith Ross Hello Royalmathmtcs, I can... 12-04-2008, 07:08 PM
Royalmathmtcs Leith, Is there a way to... 12-04-2008, 07:15 PM
Leith Ross Hello Royalmathmtcs, I... 12-04-2008, 07:24 PM
Royalmathmtcs Yes, that would be great, as... 12-04-2008, 07:28 PM
Royalmathmtcs This is working very well... 12-04-2008, 07:00 PM
  1. #1
    Registered User
    Join Date
    12-03-2008
    Location
    Chicago
    Posts
    13
    Hi Leith,

    This version looks a lot cleaner, and it appears that it will not enter duplicate industry names in the column, which is the only problem with the other code I was able to get working.

    I believe that this is to be ran with =GetIndustryType()?

    Also, if I were to add more keys with standard numbers, ie
    Keys(7) = "UL 497C"
    would I need to make this value higher?
    Dim Keys(100) As String
    Last edited by Royalmathmtcs; 12-04-2008 at 06:49 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Royalmathmtcs,

    You are correct about the macro. Since it is a UDF, it is called just like a standard worksheet formula. If you have more than 100 Standards per Industry name then you will need to increase the Keys array value. I was thinking that it might be good to load the standards from a worksheet. It would be easier to maintain and allow you to easily search for a standard, or sort them.

    Sincerely,
    Leith Ross

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Royalmathmtcs,

    I can change the macro not to error on a non existent standard. I left it that way as an alert to the user that something wasn't right. What would you like it do?

    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    12-03-2008
    Location
    Chicago
    Posts
    13
    Leith,

    Is there a way to display: (error for any non existent standard) comma (industry for defined standard)? This way the user would be notified of the error, but still be able to see if there is an industry available for the company. If not, could you explain how to make is so that it does nothing for the error, and displays the industry for the standards that have been defined, even if they are in the same cell as a non defined standard?
    Last edited by Royalmathmtcs; 12-04-2008 at 07:18 PM.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Royalmathmtcs,

    I could display the missing standards in a message box. Would that work?

    Sincerely,
    Leith Ross

  6. #6
    Registered User
    Join Date
    12-03-2008
    Location
    Chicago
    Posts
    13
    Yes, that would be great, as long as it still displays the industry for the standards that have been defined, even if they are in the same cell as a non defined standard.

    I really appreciate your time and patience...

  7. #7
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180
    Hi,


    Sub kTest()
    Dim a, i As Long, x, y, c As Long, iteAry, applAry
    iteAry = Array("UL 60950", "UL 60950-1", "UL 1459", "UL 497", "UL 497A", "UL 497B", "UL 497C", _
                "UL 1863", "UL 1310", "UL 1012", "UL 61965", "UL 60601-1", "UL 60601A-1", "UL 60601B-1", _
                "UL 60601C-1", "UL 1863")
    
    applAry = Array("UL 1286", "UL 962", "UL 1459")
    
    a = Range("m8", Range("m" & Rows.Count).End(xlUp))
    ReDim w(1 To UBound(a, 1), 1 To 1)
    
    For i = 1 To UBound(a, 1)
        x = Split(a(i, 1), ",")
        For c = 0 To UBound(x)
            y = Application.Match(Trim(x(c)), iteAry, 0)
            If Not IsError(y) Then w(i, 1) = "ITE": Exit For
        Next
        For c = 0 To UBound(x)
            y = Application.Match(Trim(x(c)), applAry, 0)
            If Not IsError(y) Then
                If Not IsEmpty(w(i, 1)) Then
                    w(i, 1) = w(i, 1) & "," & "Appliances"
                    w(i, 1) = UNIQUE(w(i, 1))
                    Exit For
                End If
            End If
        Next
    Next
    With Range("n8")
        .Resize(i - 1).Value = w
    End With
    End Sub
    Function UNIQUE(v)
    Dim x, e, i As Long
    With CreateObject("scripting.dictionary")
        .comparemode = vbTextCompare
        x = Split(v, ",")
        For i = 0 To UBound(x)
            If Not .exists(x(i)) Then
                .Add x(i), Nothing
            End If
        Next
        If .Count > 0 Then UNIQUE = Join$(.keys, ",")
    End With
    End Function
    HTH
    Kris

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1