+ Reply to Thread
Results 1 to 11 of 11

Basic Variable Error with Proper

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Basic Variable Error with Proper

    Hi, this is a little embarrasssing. I have recorded a macro to capitalise a single letter in a range of cells. I seem to be having a little trouble with assigning the variable to proper.

    This is my code

    I keep getting the error on this line, I have changed it many ways but can not get it right.

    Letter = Worksheets("ServiceDeliveryTemplate").Range("F7:F21").Text.Proper(" ")

    Please Login or Register  to view this content.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Basic Variable Error with Proper

    I can't see how you have an ActiveCell your code selects a range of cells, which cell are you working with?

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.
    Last edited by royUK; 06-28-2010 at 07:08 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Basic Variable Error with Proper

    What is that line supposed to do?

  4. #4
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Re: Basic Variable Error with Proper

    Quote Originally Posted by StephenR View Post
    What is that line supposed to do?
    The line is supposed to take the string input which will be a letter and capitalise it. Simple really. Each cell in the range specified needs to be capitalised.

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Basic Variable Error with Proper

    That looks like made-up syntax. Why not just use the PROPER formula? And perhaps address Roy's post.

  6. #6
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Re: Basic Variable Error with Proper

    I recorded the macro and then tried to edit it to get it to work. I am trying the Proper function its not working for me yet though.

    I will study up some more and will get ti should be easy get a range of letters to capitalise. Maybe just a bit late here.

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Basic Variable Error with Proper

    If you have "fred" in A1 then in another cell =PROPER(A1) will yield "Fred".

  8. #8
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Re: Basic Variable Error with Proper

    Quote Originally Posted by StephenR View Post
    If you have "fred" in A1 then in another cell =PROPER(A1) will yield "Fred".
    Agree but thats where variations of the line aren't working for me.

    Letter = Worksheets("ServiceDeliveryTemplate").Range("F7:F21").Text.Proper(" ")

    So I am defining "Letter" at the start as a String and then telling it that the strings are the range of cells Range("F7:F21") ((Well Trying)) and thenI want to pass through Proper.

    However if Change it to
    Letter = Worksheets("ServiceDeliveryTemplate").Range("F7:F21").Text
    Letter.Proper(" ")

    it is still an error because i am not getting what the "expression" is. Because help defines the Proper Function as

    Please Login or Register  to view this content.
    Last edited by flebber; 06-28-2010 at 10:07 AM. Reason: clarity

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997

    Re: Basic Variable Error with Proper

    You can't do that - you need to loop through the cells to alter them:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  10. #10
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Re: Basic Variable Error with Proper

    Thanks a million that makes sense. I am going to look up and see how you used Proper in the statement "vbPropercase".

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997

    Re: Basic Variable Error with Proper

    I used VBA's StrConv (String Conversion) function, since you're using VBA anyway. You could have used the Worksheet function from code, but it's slower - you would replace:
    Please Login or Register  to view this content.
    with either:
    Please Login or Register  to view this content.
    or:
    Please Login or Register  to view this content.

+ 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