+ Reply to Thread
Results 1 to 6 of 6

Using variable in Range in Sub

Hybrid View

  1. #1
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Using variable in Range in Sub

    Instead of
    Range("A" & r & ":S" & r).Select
        With Selection.Interior
            .ColorIndex = 15
            .Pattern = xlSolid
        End With
    Try:
    With Range("A" & r , "S" & r).Interior
       .ColorIndex = 15
       .Pattern = xlSolid
    End With
    Instead of
        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
    Try:
    Range("A" & firstrow , "A" & lastrow).ClearContents
    Range("R" & firstrow , "S" & lastrow).ClearContents
    Range("A" & firstrow , "S" & lastrow).Interior.ColorIndex = xlNone

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

    Re: Using variable in Range in Sub

    Quote Originally Posted by stnkynts View Post
    Try:
    With Range("A" & r , "S" & r).Interior
       .ColorIndex = 15
       .Pattern = xlSolid
    End With
    Try:
    Range("A" & firstrow , "A" & lastrow).ClearContents
    Range("R" & firstrow , "S" & lastrow).ClearContents
    Range("A" & firstrow , "S" & lastrow).Interior.ColorIndex = xlNone
    Thanks but got runtime error - Method chance of object global failed.

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Using variable in Range in Sub

    Could you submit your whole code or a copy of the workbook for review?

+ 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