+ Reply to Thread
Results 1 to 30 of 30

macro: excel 2003(run) to excel 2016(problem)

Hybrid View

  1. #1
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    macro: excel 2003(run) to excel 2016(problem)

    i have this macro that don't run on new excel.
    when i activate the macro the clipboard is cleared. where is the problem?. thanks all

    Sub expirydate()
    Range("AB12").Select
        Selection.Copy
        Range("AB6:AB11").Select
        Range("AB11").Activate
        Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False
        Application.CutCopyMode = False
        Range("AB6:AB11").Select
        Range("AB11").Activate
        Selection.Copy
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False
        Application.CutCopyMode = False
           Range("AA6:AB11").Select
        Range("AB11").Activate
        Selection.Sort Key1:=Range("AB12"), Order1:=xlAscending, Header:=xlGuess _
            , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        Range("Z10").Select
    End sub
    Last edited by brianjj; 01-19-2017 at 06:51 AM.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    Hi,

    Please use code tags when posting code as required by forum rules.

    You should not be able to name a routine date() as that is a VBA keyword. Perhaps this variation of your code will suffice
    Sub rundate()
        With Range("AB6:AB11")
            .FormulaR1C1 = Range("AB12").FormulaR1C1
            .Value2 = .Value2
        End With
        Range("AA6:AB11").Sort Key1:=Range("AB12"), Order1:=xlAscending, Header:=xlGuess _
                             , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        Range("Z10").Select
    End Sub
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    Quote Originally Posted by xlnitwit View Post
    Hi,

    Please use code tags when posting code as required by forum rules.
    done
    Quote Originally Posted by xlnitwit View Post
    You should not be able to name a routine date() as that is a VBA keyword. Perhaps this variation of your code will suffice
    Sub rundate()
        With Range("AB6:AB11")
            .FormulaR1C1 = Range("AB12").FormulaR1C1
            .Value2 = .Value2
        End With
        Range("AA6:AB11").Sort Key1:=Range("AB12"), Order1:=xlAscending, Header:=xlGuess _
                             , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        Range("Z10").Select
    End Sub
    it doesn't work yet.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    Quote Originally Posted by brianjj View Post
    it doesn't work yet.
    Could you be slightly more specific?

  5. #5
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    clipboard clear.
    in AB6:AB11 there must be a date. but nothing appears. if i put mouse on the cell appear 00/01/1900

    ex:
    1 20 gennaio 17
    2 17 febbraio 17
    3 17 marzo 17
    4 21 aprile 17
    6 16 giugno 17
    9 15 settembre 17
    Last edited by brianjj; 01-19-2017 at 08:42 AM.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    The code I posted doesn't use the clipboard at all. What exactly is in AB12?

  7. #7
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    AB12:
    =SE(VAL.ERRORE(CERCA.VERT(AA12;'gestione portafoglio'!$CW$10:$CX$21;2));0;(CERCA.VERT(AA12;'gestione portafoglio'!$CW$10:$CX$21;2)))

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    Then I would assume that your lookup values in column AA6:AA1 are not being found for some reason, hence your formula returns 0. The clipboard is not a factor.

  9. #9
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    AA6:AA11 are numbers that i put manually indicate month

    in my ex before 1 is for january.. 2 for february, 9 to september... and so on

    always third friday of the month. it is for expiry date in stock exchange
    Last edited by brianjj; 01-19-2017 at 09:01 AM.

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    Unless you can post a workbook that shows differently I still believe that your data is the problem.

    Change the formula in AB12 to this
    =CERCA.VERT(AA12;'gestione portafoglio'!$CW$10:$CX$21;2)

    and re-run the code and tell me what is in A6:A11 at the end, please.

  11. #11
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    in AB12 appears: #N/D
    and in AB6:AB11 : #NOME?

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    So the lookup is definitely failing for AB12.

    If you change the code to this and run it- with the new formula- what is in AB6:AB11 at the end
    Sub rundate()
        With Range("AB6:AB11")
            .FormulaR1C1 = Range("AB12").FormulaR1C1
     '       .Value2 = .Value2
        End With
        Range("AA6:AB11").Sort Key1:=Range("AB12"), Order1:=xlAscending, Header:=xlGuess _
                             , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        Range("Z10").Select
    End Sub

  13. #13
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    Ab6:ab11 : #nome?

  14. #14
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    There should be a formula in those cells after running that.

  15. #15
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    changing only the vba code: cells are clear but in there is the original formula.
    changing also the new formula: appears #NOME? and under there is the new formula

  16. #16
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    So you get all formulas and they result in #N/D in AB12 but #NOME? in AB6:AB11?

  17. #17
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    changing only the vba code: AB6:AB11 cells are clear but in there is the original formula. AB12 is 0

    changing also with the yours "new formula": in AB6:AB11 appears #NOME? and under there is the new formula. AB12 is #N/D

  18. #18
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    I don't really understand how you can have the same formula working in AB12 but not even calculating in AB6:AB11. Can you try this code with the new formula
    Sub rundate()
            Range("AB12").Copy 
           Range("AB6:AB11").PasteSpecial xlPasteFormulas
        Range("AA6:AB11").Sort Key1:=Range("AB12"), Order1:=xlAscending, Header:=xlGuess _
                             , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        Range("Z10").Select
    End Sub
    and tell me what appears in each cell?

  19. #19
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    AB6:AB11 cells are clear, nothing appears.
    if i go on and click one of these cells appear the formula that we have in AB12 (changed AA11 or AA9 ...exc.)

  20. #20
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    What is the result of the formulas?

  21. #21
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    with AA6: "1" must be 20 january 2017
    AA7: "2" must be 17 february 2017

    but, nothing appears, no results. seem that copy only the formula on AB12

  22. #22
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    What is the formula in AB6 now?

    Perhaps you could post a sample workbook?

  23. #23
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    AB6 became: =SE(VAL.ERRORE(CERCA.VERT(AA6;'gestione portafoglio'!$CW$10:$CX$21;2));0;(CERCA.VERT(AA6;'gestione portafoglio'!$CW$10:$CX$21;2)))

    but no result

  24. #24
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    AB6 became: =SE(VAL.ERRORE(CERCA.VERT(AA6;'gestione portafoglio'!$CW$10:$CX$21;2));0;(CERCA.VERT(AA6;'gestione portafoglio'!$CW$10:$CX$21;2)))

    but no result
    Attached Files Attached Files
    Last edited by brianjj; 01-19-2017 at 12:01 PM.

  25. #25
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    this is what i have.
    i'm not able to insert the macro.
    when a manually type numbers 1 to 12 e push the buttom of the macro in the cell appear the expity date of that month (third fryday)

  26. #26
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    why it run on excel 2003 and not now on the new one?
    probably there is a code that the new excel don't recognize

  27. #27
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    Then I can only presume that your formula is not finding a match for the lookup value and therefore returning 0, and that you have set Excel to suppress the display of 0 values.

    Your sample workbook doesn't actually help since it does not contain the source sheet with the lookup table.

  28. #28
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: macro: excel 2003(run) to excel 2016(problem)

    There are no differences between those formulas in 2003 and 2016. As you have not provided the lookup table I can't say why it does not work for you.

  29. #29
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    in another macro i add a string and it works. i think also in this one maybe is the same but i don't know where and what.
    for now, thank you for your time.

  30. #30
    Registered User
    Join Date
    01-19-2017
    Location
    italy
    MS-Off Ver
    windows 10
    Posts
    17

    Re: macro: excel 2003(run) to excel 2016(problem)

    in another macro i add a string and it works. i think also in this one maybe is the same but i don't know where and what.
    for now, thank you for your time.

+ 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. [SOLVED] Problem with pasting picture in Excel 2016
    By louiserace in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2016, 04:18 AM
  2. Problem running Auto_Open from add-ins in Excel 2013 and 2016
    By Cashgenerator in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-24-2016, 08:53 AM
  3. [SOLVED] problem with filter in excel 2016
    By pongmeister in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-04-2016, 04:13 PM
  4. Problem with nested if in excel 2016
    By araujo3rd in forum Excel General
    Replies: 2
    Last Post: 04-01-2016, 04:50 AM
  5. Help: Problem with Solver in Excel 2016
    By baballan in forum Excel General
    Replies: 0
    Last Post: 02-17-2016, 04:03 AM
  6. Excel 2016 Problem
    By lgchandana in forum Excel General
    Replies: 4
    Last Post: 12-16-2015, 06:07 AM
  7. Problem with Excel 2003 macro in Excel 2010.
    By madiaz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2013, 03:27 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