Results 1 to 5 of 5

Thread: [RESOLVED] trim function

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    2

    Resolved [RESOLVED] trim function

    Hi

    I'm hoping somebody can help me. I'm just starting to learn about VB and am trying to write a function for Excel which will trim the cells I highlight. The idea is to have a custom button which will do this (eg clicking the bold button in Excel changes font to bold). Can anybody help?

    Cheers
    Sean

  2. #2

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: trim function

    create a commandbutton on the sheet where you want the cells to be trimed.

    paste the below mentioned code in the command button code.

    VB Code:
    1. trim(activecell.value)

    make sure you highlight the cell whose value you need to trim before you click the command button. i am assuming that you know that the trim function is used for stings only.

    suggestion: the best best way to learn is to let the macros do what you want to do and then amend the code

    hope this helps...

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    2

    Re: trim function

    Thanks, followed your advice about using a macro and it's helped me understand the code a bit better. Problem solved.

    Cheers
    Sean

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: trim function

    Now that we've helped you, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer. Also if someone has been particularly helpful, or even particularly unhelpful, you have the ability to affect a their forum "reputation" by rating their post.

    .

Posting Permissions

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



Click Here to Expand Forum to Full Width