+ Reply to Thread
Results 1 to 2 of 2

"Compile error: Method or data member not found", code needs fix

Hybrid View

  1. #1
    Registered User
    Join Date
    03-14-2007
    Posts
    3

    Exclamation "Compile error: Method or data member not found", code needs fix

    Code:
        If Sheet6.Range("O8").Value = 4 Then
        
            For Each cell In Sheet10.Range("B5", "B369")
            
                If (cell.Value = Sheet6.Range("L24").Value) Then
                
                    cell.Offset(0, Sheet6.Range("L21").Value).Value = Sheet1.ActiveCell.Value
                                    
                End If
                
            Next cell
            
        End If
    it says the part of code causing the error is the end of the 'cell.offset' part, as highlighed:

    Sheet1.ActiveCell.Value

    i tried replacing it with '.Selection', still get the same error.

    any one got the magic solution?
    Last edited by cheeky; 03-29-2007 at 07:35 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,259
    Hello Cheeky,

    ActiveCell is not a Worksheet object, but a global Application object. As such it doesn't require you to qualify it with a parent object, i.e. Worksheet name. Excel will take the ActiveCell from the ActiveSheet. If you need "Sheet1" active then you need to place that in the code. I have done so for you and made it comment. You can remove the single quote if you need "Sheet1" active.

        If Sheet6.Range("O8").Value = 4 Then
        
            For Each cell In Sheet10.Range("B5", "B369")
            
                If (cell.Value = Sheet6.Range("L24").Value) Then
                    'Sheet1.Activate
                    cell.Offset(0, Sheet6.Range("L21").Value).Value = ActiveCell.Value
                                    
                End If
                
            Next cell
            
        End If
    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