+ Reply to Thread
Results 1 to 13 of 13

Convert nested if function to vba code

  1. #1
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Convert nested if function to vba code

    Greetings,
    1- Open enclosed file.
    2- Look function in the C2 cell.
    3- Click save macro button.
    4- Select C2 cell and press F2.
    5- Stop saving macro.
    6- Look at saved macro on VBE Editor.

    Question:
    Why code in the VBE Editor color is red ?
    In order words why code in the VBE Editor has an error?

    Thanks in advance.
    Attached Files Attached Files
    Sub DontForgetThese()
         If Your thread includes any code Then Please use code tags...
         If Your thread has been solved Then Please mark as solved...
         If Anybody has helped to you Then Please add reputation...
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert nested if function to vba code

    I have not saved your file, but you can copy the ifs statement from the formula bar to VBA, but you need to change "" in to """"

  3. #3
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: Convert nested if function to vba code

    Hi AB33,
    Thanks for answer but I dont understand how to do it.

  4. #4
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: Convert nested if function to vba code

    I put following link below just for information...
    http://support.microsoft.com/kb/141513/en-us

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert nested if function to vba code

    No, I believe, you can not do a one line continuation with formula in VBA. I think it has to be a single line.
    Corrected. I think you may use " & " to continue as a single line.
    Last edited by AB33; 01-30-2015 at 02:27 PM.

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

    Re: Convert nested if function to vba code

    How about a simpler formula? in C2,

    =VLOOKUP(LEFT(A2, 2), $E$2:$F$27, 2, 0)

    Row\Col
    A
    B
    C
    D
    E
    F
    1
    Kodu Adı Title
    2
    AKDDG AKBNK C 270215 0008.00 DBL 001:001 NA AKBNK AK AKBNK
    3
    AKDDH AKBNK C 270215 0008.70 DBL 001:001 NA AKBNK AQ ONS ALTIN QUANTO
    4
    AQIAF XAUSQ C 270215 1400.00 IYM 100:001 NA ONS ALTIN QUANTO AX ONS ALTIN FLEXO
    5
    AQIRT XAUSQ P 300615 1100.00 IYM 100:001 NA ONS ALTIN QUANTO DJ DWJNS
    6
    AQIRU XAUSQ P 300615 1000.00 IYM 100:001 NA ONS ALTIN QUANTO DU DUELLO
    7
    AXIAF XAUSX C 270215 1400.00 IYM 100:001 NA ONS ALTIN FLEXO DX DAX
    8
    AXIRT XAUSX P 300615 1100.00 IYM 100:001 NA ONS ALTIN FLEXO EK EKGYO
    9
    AXIRU XAUSX P 300615 1000.00 IYM 100:001 NA ONS ALTIN FLEXO ER EREGL
    10
    DJDAA DWJNS C 300415 18500.0 DBL 000.001 NA DWJNS EU STOXX
    11
    DJDAB DWJNS C 300415 17750.0 DBL 000.001 NA DWJNS FT FTSE
    12
    DJDPP DWJNS P 300415 16000.0 DBL 000.001 NA DWJNS FX EUR/USD
    13
    DJDPR DWJNS P 300415 15250.0 DBL 000.001 NA DWJNS GA GARAN
    14
    DUIPP AK/YK P 270215 0001.60 IYM 0000005 NA DUELLO HA HALKB
    15
    DUIPR KC/SA P 270215 0001.10 IYM 0000010 NA DUELLO IS ISCTR
    16
    DUIPS GA/ER P 270215 0001.80 IYM 0000005 NA DUELLO KC KCHOL
    17
    DXDCF DAX C 200315 10000.0 DBL 000.001 NA DAX NA NASDQ
    18
    DXDCG DAX C 200315 10400.0 DBL 000.001 NA DAX NK NIKKE
    19
    DXDUZ DAX P 200315 8600.00 DBL 000.001 NA DAX OZ XU030
    20
    DXDVP DAX P 300415 8800.00 DBL 000.001 NA DAX SA SAHOL
    21
    DXDVR DAX P 300415 9200.00 DBL 000.001 NA DAX SP SP500
    22
    EKDDG EKGYO C 270215 0002.50 DBL 001:002 NA EKGYO TH THYAO
    23
    EKITY EKGYO P 310315 0002.40 IYM 001:002 NA EKGYO TT TTKOM
    24
    EKITZ EKGYO P 310315 0002.20 IYM 001:002 NA EKGYO TU TUPRS
    25
    EKIUP EKGYO P 300415 0003.15 IYM 001:002 NA EKGYO US USD
    26
    EKIUR EKGYO P 300415 0002.85 IYM 001:002 NA EKGYO VA VAKBN
    27
    EKIUS EKGYO P 300415 0002.70 IYM 001:002 NA EKGYO YK YKBNK
    28
    ERDDF EREGL C 270215 0004.50 DBL 001:002 NA
    29
    ERITV EREGL P 300415 0005.00 IYM 001:002 NA
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert nested if function to vba code

    This is the first code with out &

    Please Login or Register  to view this content.
    End Sub[/CODE]

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert nested if function to vba code

    See if this works. I did not see the red line error, but I am not sure if it is the right syntax


    Please Login or Register  to view this content.

  9. #9
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: Convert nested if function to vba code

    Quote Originally Posted by AB33 View Post
    See if this works. I did not see the red line error, but I am not sure if it is the right syntax
    No, not working.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert nested if function to vba code

    Wrong comment.
    Last edited by AB33; 01-31-2015 at 08:42 AM.

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert nested if function to vba code

    Funny!
    I left out one "" with a single quote, hence for the error.

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert nested if function to vba code

    This code completes the fill down column C.

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: Convert nested if function to vba code

    Thanks a lot Solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. convert text string to cell address to use in a nested function
    By scrid in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-18-2012, 02:53 AM
  2. [SOLVED] how to convert the vlookup function to vba code
    By funtastic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2012, 06:50 PM
  3. Convert General Format to Date, Nested IF Function, If Yes then highlight row
    By woody04 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-21-2012, 05:01 AM
  4. Code to Assist with Nested Function, Also Using ISERROR
    By Paige in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2006, 09:50 AM
  5. [SOLVED] Help: Nested If/And Function formula to VB code
    By RAP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2005, 01:05 AM

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