+ Reply to Thread
Results 1 to 12 of 12

Writing VBA Macro or Excel Function

  1. #1
    Registered User
    Join Date
    11-05-2007
    Posts
    8

    Writing VBA Macro or Excel Function

    Hi all,
    I have Asset Class in Column I and if it is 364A-EL or 365A-EL or 368A-EL or 368B-EL or 369A-EL or 371A-EL or 371B-EL or 373A-EL or 397C-EL then 'POLES' assigned in to Owner Class (Column J).

    If Asset Class is 366A-EL or 367A-EL or 367B-EL or 368C-EL or 369B-EL or 371C-EL or 373B-EL then assign UGCBL to Owner Class.

    Should we write the macro or can it be accomplished by any Excel Function?

    Could you please help in writing the Macro or Function, PLEASE ?

    Thanks,
    Venkat.

  2. #2
    Forum Contributor
    Join Date
    12-12-2006
    Location
    New Zealand
    Posts
    151
    You could list your first values in column k and you second list of values in column L then use this formula (in J1) to check the value in I1:

    =IF(COUNTIF(K:K,I1)>0,"POLES",IF(COUNTIF(L:L,I1)>0,"UGCBL","Not Found"))
    Last edited by Reafidy; 11-05-2007 at 03:58 PM.
    Reafidy.

    Tip: When using code and disabling events/screen updates/calculation be sure to use an error handler to turn them back on if an error occurs.

  3. #3
    Registered User
    Join Date
    11-05-2007
    Posts
    8
    Hi Reafidy,

    Thank you for your reply.

    Depending on the values in Asset Class (Column I) I wanto to assign POLES or UGCBL or XXXX into Owner Class (Column J).

    You are asking to list first values in column K and second list of values in column L, but I can not list those values into two separate columns, PLEASE?

    Thanks,
    Venkat.

  4. #4
    Forum Contributor
    Join Date
    12-12-2006
    Location
    New Zealand
    Posts
    151
    Can you explain why you cant put the values into a list please.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    They don't need to occupy a full column; they can be in any named ranges tucked away anyplace on the sheet, or elsewhere in the workbook.

    You really don't want to hard-code these into a big long formula.

  6. #6
    Forum Contributor
    Join Date
    12-12-2006
    Location
    New Zealand
    Posts
    151
    Quote Originally Posted by shg
    They don't need to occupy a full column; they can be in any named ranges tucked away anyplace on the sheet, or elsewhere in the workbook.

    You really don't want to hard-code these into a big long formula.
    Exactly.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    ... but if you did, the formula would look like,

    =if( or(A1 = {"blah1", "blah2", "blah3", ....}), "POLES", if( or(A1 = {"blahx", "blahy", "blahz", ...}), "UGCBL", "neither") )

  8. #8
    Registered User
    Join Date
    11-05-2007
    Posts
    8
    Hi shg,
    Thank you for your reply.

    I am working on SAP BW BEx Report and I am trying to accomplish the requirement on front-end side instead of doing it on back-end.

    I have entered the function as:

    =IF( OR(I20 = {"364A-EL","365A-EL","368A-EL","368B-EL","369A-EL","371A-EL","371B-EL","373A-EL","397-EL"}),"POLES"), IF( OR(I20 = {"366A-EL","367A-EL","367B-EL","368C-EL","369B-EL","371C-EL","373B-EL"}),"UGCBL"), IF(I20 = "370A-EL","METER") and it was giving the error '#VALUE!'.

    Next I changed it to the following and got the same error '#VALUE!':

    =IF( OR(I20 = {"364A-EL","365A-EL","368A-EL","368B-EL","369A-EL","371A-EL","371B-EL","373A-EL","397-EL"}),"POLES"), IF( OR(I20 = {"366A-EL","367A-EL","367B-EL","368C-EL","369B-EL","371C-EL","373B-EL"}),"UGCBL")

    Next I have tried with only partial data and worked correctly and gave 'POLES' for the First Row:

    =IF( OR(I20 = {"364A-EL","365A-EL","368A-EL","368B-EL","369A-EL","371A-EL","371B-EL","373A-EL","397-EL"}),"POLES")

    Some how it is not working for the second IF.
    Could you please verify the syntax and help me, PLEASE ?

    Thanks,
    Venkat.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Misplaced paren:

    =IF( OR(I20 = {"364A-EL","365A-EL","368A-EL","368B-EL","369A-EL","371A-EL","371B-EL","373A-EL","397-EL"}),"POLES", IF( OR(I20 = {"366A-EL","367A-EL","367B-EL","368C-EL","369B-EL","371C-EL","373B-EL"}),"UGCBL", "neither") )

  10. #10
    Registered User
    Join Date
    11-05-2007
    Posts
    8
    Hi shg,
    Thanks a lot for your great help. It WORKED !!!

    Regards,
    Venkat.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Ta da! You're welcome

    BTW, when you're having trouble entering a formula, especially those with nested functions, watch the tooltip that appears below the formula bar. It highlights the argument of the function you're entering. If it doesn't agree with what you think you're entering, believe it and not you ...
    Last edited by shg; 11-05-2007 at 07:14 PM.

  12. #12
    Registered User
    Join Date
    11-05-2007
    Posts
    8
    Got the solution.
    Last edited by venkat_kodi; 11-06-2007 at 07:44 PM.

+ 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