Results 1 to 6 of 6

Using variable in Range in Sub

Threaded View

  1. #1
    Registered User
    Join Date
    03-03-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    53

    Using variable in Range in Sub

    Hi

    I seem to be confusing the use of variables in ranges somehow so would appreciate help. The code below is intended to highlight one row as defined by the variable r which is a for next counter, but instead it highlights the whole sheet.

    Range("A" & r & ":S" & r).Select
        With Selection.Interior
            .ColorIndex = 15
            .Pattern = xlSolid
        End With
    The routines below to clear certain columns and remove all formatting before running work fine but these variables are not part of a loop counter.
        Range("A" & firstrow & ":A" & lastrow).Select
        Selection.clearcontents
        
        Range("R" & firstrow & ":S" & lastrow).Select
        Selection.clearcontents
    
        Range("A" & firstrow & ":S" & lastrow).Select
        Selection.Interior.ColorIndex = xlNone
    Some insight from the more experienced as to what I am doing wrong would be greatly appreciated.
    Last edited by Orada; 03-03-2011 at 12:48 PM.

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