+ Reply to Thread
Results 1 to 14 of 14

Combining Two Scripts

  1. #1
    Registered User
    Join Date
    06-29-2008
    Location
    Perth, Australia
    MS-Off Ver
    MS Office 2003
    Posts
    87

    Combining Two Scripts


    I have one script which converts cell entries to upper case and goes like this:
    Please Login or Register  to view this content.
    I have another script that highlights the row and column of the selected cell, and goes like this:
    Please Login or Register  to view this content.
    How do I combine the two scripts so that both the features work?

    Thanks in advance.
    Last edited by BazzaBoy; 09-13-2010 at 04:57 AM.

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

    Re: Combining Two Scripts

    Combine them to do what? One works when a cell on the sheet changes, and the other when the selection changes. When do you want them both to run?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-29-2008
    Location
    Perth, Australia
    MS-Off Ver
    MS Office 2003
    Posts
    87

    Re: Combining Two Scripts

    All the time.... I suppose.

    Sorry shg, I am not a programmer, so I am not getting what you mean. I don't even know, if they need to be combined. If I use them as they are in the worksheet code for sheet 1, I get an error 1004.

    I just want them to do what they each do.... all the time.

    Regards.

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

    Re: Combining Two Scripts

    If I use them as they are in the worksheet code for sheet 1, I get an error 1004.
    Under what circumstances? What line gives the error?

  5. #5
    Registered User
    Join Date
    06-29-2008
    Location
    Perth, Australia
    MS-Off Ver
    MS Office 2003
    Posts
    87

    Re: Combining Two Scripts


    If I use both scripts together (one below the other) in a fresh workbook as follows:
    Please Login or Register  to view this content.
    then all works well.

    But if I use them in one of my existing workbooks, it gives me an error in the line ".ColorIndex = 20". The prompt says: "Unable to set the ColorIndex property of the Interior class" (see attached).

    FYI, I have two sheets in the workbook. sheet1 is labelled 'Members' and sheet2 is labelled 'Analysis'.

    I don't understand why both features will work in a fresh workbook, but not in my existing workbook.
    Attached Images Attached Images

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combining Two Scripts

    Start reading the code and try to understand what is does and what it is meant for.

    Please Login or Register  to view this content.
    Last edited by snb; 09-11-2010 at 07:36 AM.



  7. #7
    Registered User
    Join Date
    06-29-2008
    Location
    Perth, Australia
    MS-Off Ver
    MS Office 2003
    Posts
    87

    Re: Combining Two Scripts


    Sorry snb,

    Your script does not work. Not even in a fresh worksheet.

    However, I have done some more digging and found that I am getting an error because the worksheet is protected. If the workshett is not protected, then everything works well. But I need my worksheet to be protected. So I'll just forget about running this script.

    Is there any other way, I can know which cell is selected?

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

    Re: Combining Two Scripts

    Your code can unprotect the worksheet, the reprotect it when it's done. See Help for the Protect method.

  9. #9
    Registered User
    Join Date
    06-29-2008
    Location
    Perth, Australia
    MS-Off Ver
    MS Office 2003
    Posts
    87

    Re: Combining Two Scripts

    Thanks shg,

    Yes, I can do that. But I also noticed that while it highlights the selected cell, it also removes background colours from all other cells. That is not good, as some of my heading cells have been assigned background colours.

    If somehow, I can define a range in the script, then maybe it would be worth unprotecting and re-protecting the sheet before and after every move.

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combining Two Scripts

    Only a slight modification:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-29-2008
    Location
    Perth, Australia
    MS-Off Ver
    MS Office 2003
    Posts
    87

    Re: Combining Two Scripts

    Thanks snb,

    It works now, but how do I prevent the script from removing background colours from my heading cells. I would like this script to affect cells A8:AE100 only. Where can I define that range in this script?

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combining Two Scripts

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    06-29-2008
    Location
    Perth, Australia
    MS-Off Ver
    MS Office 2003
    Posts
    87

    Re: Combining Two Scripts

    Thank you very much snb,

    It's all working very well now. Thanks again for your input and your help.

    You can mark this thread as 'solved'.

    Regards.

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combining Two Scripts

    I can't, you can (and must, if ...)

+ 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