Results 1 to 5 of 5

Function Chr() in VBA with Excel 2010

This is a discussion on Function Chr() in VBA with Excel 2010 within the Excel Questions forums, part of the Question Forums category; ****** http-equiv="Content-Type" content="text/html; charset=utf-8">****** name="ProgId" content="Word.Document">****** name="Generator" content="Microsoft Word 14">****** name="Originator" content="Microsoft Word 14"> Normal 0 false false false EN-US ...

  1. #1
    New Member
    Join Date
    Jun 2010
    Posts
    2

    Default Function Chr() in VBA with Excel 2010

    ****** http-equiv="Content-Type" content="text/html; charset=utf-8">****** name="ProgId" content="Word.Document">****** name="Generator" content="Microsoft Word 14">****** name="Originator" content="Microsoft Word 14"> Hello,

    I have a program which could perfectly run on Excel 2003 Pro but not on Excel 2010 Pro.

    I solved the first problem. You cannot declare a variable as dictionary anymore, you need to put Scripting.Dictionary.

    But I spent more than one hour on the second one and cannot figure out the solution. I use the function Chr in the following case (I removed the code that had nothing to do with my problem):

    Dim TermRInit As Integer
    TermRInit = 7
    Dim cRatioRefCell As String
    cRatioRefCell = Chr(TermCInit + 64) & TermRInit

    I receive the following compilation error:
    "Compile error:

    Can't find project or library"

    It comes from Chr but this function is defined in Excel 2010 Help...

    I really don't understand what is the problem. I think that I have to add a library but I don't know which one....

    Thanks for your help.
    Helo

  2. #2
    MrExcel MVP
    Moderator
    Scott Huish's Avatar
    Join Date
    Mar 2004
    Location
    Oregon
    Posts
    17,147

    Default Re: Function Chr() in VBA with Excel 2010

    I don't have XL2010, but why are you referring to the column by it's letter, why not just use its number?
    Office 2007/2010

  3. #3
    New Member
    Join Date
    Jun 2010
    Posts
    2

    Default Re: Function Chr() in VBA with Excel 2010

    In fact, my code is a several pages code. I decided to only quote a small part of it.

    I have a For loop that changes the values of TermCInit(for the column) and TermRInit for the Row. By the way, I forgot to declare TermCInit in this part of the code but it has been done in my program.

    The objective of this part of the code is to write down formulas in cells.

    I indeed want to write down formulas like "=Sum(A2:CE41)".If I cannot find a solution to the problem, I'll create a table numberToLetter of size 104 and write down:
    numberToLetter(1)="A"
    numberToLetter(2)="B"
    numberToLetter(3)="C"
    numberToLetter(4)="D"
    ...
    numberToLetter(103)="DY"
    numberToLetter(104)="DZ"

    But that's a cumbersome way of doing. Furthermore, my code was working when I could use the function Chr in Excel 2003!!!!

    Thanks

  4. #4
    MrExcel MVP
    Moderator
    Scott Huish's Avatar
    Join Date
    Mar 2004
    Location
    Oregon
    Posts
    17,147

    Default Re: Function Chr() in VBA with Excel 2010

    As I said I don't have Excel 2010, but what I am saying is you probably don't need to use the range letters at all, this is not usually necessary. You may not even need a loop. What is it you are trying to do exactly? There are also much easier ways to get column letters. You can use Cells to use the column number.
    Office 2007/2010

  5. #5
    Board Regular
    Join Date
    Jun 2010
    Posts
    56

    Default Re: Function Chr() in VBA with Excel 2010

    I guess , your pc had an earlier version of Excel.
    You have to delete .exd files.
    See this;
    http://www.dailydoseofexcel.com/arch...ompile-errors/

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com