+ Reply to Thread
Results 1 to 6 of 6

error 1004 select method of range class failed

Hybrid View

  1. #1
    Registered User
    Join Date
    03-23-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    14

    error 1004 select method of range class failed

    Hi my code is not working but looks correct please have a look, I have debugged it and put the bit which it told me to correct in green below:

    
    Dim friCost As Range
    Dim friPrice As Variant
    Dim totalFriPrice As Currency
    
    Range("A1").Select
    
    x = ActiveCell.CurrentRegion.Rows.Count 'This uses x to locate the active cell
    
    Set friCost = Worksheets("Bookings").Range("A2:A" & x) 'This sets the range
    
    
    For Each friPrice In friCost
    
        
        If friPrice = "Friday 4th October" Then
        
           friPrice.Select
            totalFriPrice = totalFriPrice + ActiveCell.Offset(0, 3).Value
        
        End If
            
            
    Next
            
    MsgBox ("Friday Income = £" & totalFriPrice)
    Last edited by Lee_wwfc; 03-23-2013 at 12:10 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: error 1004 select method of range class failed

    Do you actually need that line?

    Instead of using ActiveCell in the next line use friPrice.

    PS Please edit your post to add code tags.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-23-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: error 1004 select method of range class failed

    Thankyou soo much it has worked
    Lee
    Last edited by Lee_wwfc; 03-23-2013 at 12:19 PM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: error 1004 select method of range class failed

    This should work as long as you have numeric data in column D.
    Dim friCost As Range
    Dim friPrice As Range
    Dim totalFriPrice As Currency
    Dim x As Long
    
    
        x = Range("A1").CurrentRegion.Rows.Count    'This uses x to locate the active cell
    
        Set friCost = Worksheets("Bookings").Range("A2:A" & x)    'This sets the range
    
        For Each friPrice In friCost
    
            If friPrice.Value = "Friday 4th October" Then
    
                totalFriPrice = totalFriPrice + friPrice.Offset(0, 3).Value
    
            End If
    
        Next
    
        MsgBox ("Friday Income = £" & totalFriPrice)

  5. #5
    Registered User
    Join Date
    03-23-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: error 1004 select method of range class failed

    Thankyou it has worked and you have fixed my system haha thankyou :D

  6. #6
    Registered User
    Join Date
    03-23-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: error 1004 select method of range class failed

    Hi i wonder if you also know how to do this below : :D

    I am making a seating plan which first you have to select a row A-L then you need to select
    a seat but there are different numbers of seats within the rows so when i book a seat in row A
    and select seat 20 it comes up as an error as it doesn't exist but how do i enable a message box to appear instead
    saying 'sorry this seat does not exist' If you know how to do this please would you tell me.
    Thankyou :D

+ 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