+ Reply to Thread
Results 1 to 9 of 9

Paste disabled

Hybrid View

  1. #1
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Sounds like the worksheet is protected.

  2. #2
    Registered User
    Join Date
    10-31-2007
    Posts
    6
    I have narrowed it down to the following bit of code!

     Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    For Each cell In Range("F5:F1000")
    If cell > "" Then
    cell.EntireRow.Interior.ColorIndex = 6  
    Else
    cell.EntireRow.Interior.ColorIndex = xlNone
    End If
    
    Next cell
    
    End Sub


    If (cell.EntireRow.Interior.ColorIndex = 6) and ('cell.EntireRow.Interior.ColorIndex = xlNone) are removed, then Paste works!

    Can anyone tell me what is going on and how to fix it?

    Here iis an example
    sample4.zip
    Last edited by VBA Noob; 11-09-2007 at 12:54 PM.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    You forgot to tell us there was code in the workbook?

  4. #4
    Registered User
    Join Date
    10-31-2007
    Posts
    6
    Quote Originally Posted by shg
    You forgot to tell us there was code in the workbook?
    Sorry about that!

    It's in the Distimport sheet!

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

    I downloaded your workbook to see what the problem was. I changed your macro some , and moved it into the Worksheet_Change(ByVal Target As Range) event procedure. Everything works. Paste will be grayed out whenever the clipboard is empty. Here is the macro I used. I am running Office 2003 on Windows XP.
    Private Sub Worksheet_Change(ByVal Target As Range)
      
        With Target
          If .Row >= 5 And .Row <= 1000 Then
            If Cells(.Row, "F") <> "" Then
               .EntireRow.Interior.ColorIndex = 6
            Else
               .EntireRow.Interior.ColorIndex = xlNone
            End If
          End If
        End With
    
    End Sub
    Sincerely,
    Leith Ross

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Couldn't those event routines be substituted by Conditional Formatting? Or is there some other routine that checks for cell color?

  7. #7
    Registered User
    Join Date
    10-31-2007
    Posts
    6
    Thanks so much for the help Leith and mikerickson!
    I've got a lot to learn about Excel Programming so my technique might not be the best!
    Conditional formatting may be a better option.
    Can anyone tell me why paste is disabled in the SelectionChange event and not the change event after the following code is executed?

    cell.EntireRow.Interior.ColorIndex = 6"
    Last edited by VBA Noob; 11-11-2007 at 11:06 AM.

+ 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