+ Reply to Thread
Results 1 to 7 of 7

Extending a Macro

  1. #1
    Valued Forum Contributor
    Join Date
    09-23-2005
    Location
    Bristol, UK
    MS-Off Ver
    2007
    Posts
    664

    Extending a Macro

    Hi all,

    I'm using the following macro to pick up a cell's color and change the text to the same color:
    Please Login or Register  to view this content.

    However, I now want to extend this so that within a range (G7:EZ201) I run the macro and it colors the whole lot. Within this range there will be a number of different colored cells.

    Can anyone suggest how to either extend my current VBA, or suggest an alternative?

    TIA,

    SamuelT
    Last edited by VBA Noob; 02-22-2007 at 01:15 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello SamuelT,

    You can do it by stepping through each cell in the Range.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Valued Forum Contributor
    Join Date
    09-23-2005
    Location
    Bristol, UK
    MS-Off Ver
    2007
    Posts
    664
    Hi Leith,

    Thanks for the suggestion. Unfortunately, when I run your script I get 'Compile error: For without next" error message.

    Any ideas?

    TIA,

    SamuelT

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello SamuelT,

    Sorry about that, I confess I'm not a good typist. Here is the corrected code...

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Samuel,

    Please wrap code next time otherwise your posts will be deleted. I've done it for you this time

    VBA Noob

    Quote Originally Posted by SamuelT
    Hi all,

    I'm using the following macro to pick up a cell's color and change the text to the same color:
    Please Login or Register  to view this content.

    However, I now want to extend this so that within a range (G7:EZ201) I run the macro and it colors the whole lot. Within this range there will be a number of different colored cells.

    Can anyone suggest how to either extend my current VBA, or suggest an alternative?

    TIA,

    SamuelT
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  6. #6
    Valued Forum Contributor
    Join Date
    09-23-2005
    Location
    Bristol, UK
    MS-Off Ver
    2007
    Posts
    664
    Firstly - apologies, will wrap from hereafter.

    Also, still no joy with the code. I'm not getting a "Run time error '1004': Unable to set ColorIndex property of the Font class".

    Another typo perhaps.

    Thanks,

    SamuelT

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello SamuelT,

    This is one of the few times the cell has to be selected for the macro to function properly...

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

+ 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