+ Reply to Thread
Results 1 to 2 of 2

How to: Format a row with a info given in a cell

  1. #1
    Registered User
    Join Date
    05-12-2005
    Posts
    3

    Exclamation How to: Format a row with a info given in a cell

    Hi all,
    I trying to format a row using formulae.

    For example:
    In cell "A3", if the length of the word is 2, then the Row should be colored grey.

    This shud fall into a loop between row 3 to 200.

    To begin with, I tried this, (without looping between rows 1 to 200)

    Sub Format()
    Range("A1").Select
    If LenB("A1") = 2 Then
    Selection.Interior.ColorIndex = 16
    End If
    End Sub


    But even this didnt work.

    Please suggest a solution!

    Thanks

  2. #2
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    It doesn't help that Format is a key word in VBA.

    I've done this in 2 different ways. THe first way follows your basic structure, I then modified it to use CASE instead of IF. You will find it easier to maintain your code using CASE. If you increase the number of rules, just increase the number of CASE statements without upping things to a horrific number of nested IF's...

    I hope this helps.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Martin Short

+ 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