End With Error

skull_eagle

Board Regular
Joined
Mar 25, 2011
Messages
89
Hi,

I keep getting an End With without With Error.

I'm not sure why as I clearly have a With statement.

Any help would be much appreciated.

Thank you




VBA Code:
Dim State As String
Dim Site As String
Dim wsST As Worksheet
Dim wsRst


State = FindForm.Controls("CM_State").Value
Site = FindForm.Controls("CM_Site").Value

wsRst = Worksheets("Results")
wsST = Worksheets(State)

    wsST.Activate

        Firstrow = Rows(6)
        Lastrow = wsST.Range("B500000").End(xlUp).Row

        For Lrow = Lastrow To Firstrow Step -1

            With wsST.Cells(Lrow, 2)

                If Not IsError(.Value) Then

                    If .Value = Site Then
                    
                    wsST.Range(Cells(Lrow, 2), Cells(Lrow + 7, 10)).Copy
                    Rows(Lrow & ":" & Lrow + 7).Copy wsRst.Range("3:10")
                        
                End If

            End With

        Next Lrow
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You missed an "End If"
Rich (BB code):
            With wsST.Cells(Lrow, 2)

                If Not IsError(.Value) Then

                    If .Value = Site Then
                    
                    wsST.Range(Cells(Lrow, 2), Cells(Lrow + 7, 10)).Copy
                    Rows(Lrow & ":" & Lrow + 7).Copy wsRst.Range("3:10")
                    
                    End If   '<-----
                        
                End If

            End With
 
Upvote 1
Solution
You missed an "End If"
Rich (BB code):
            With wsST.Cells(Lrow, 2)

                If Not IsError(.Value) Then

                    If .Value = Site Then
                   
                    wsST.Range(Cells(Lrow, 2), Cells(Lrow + 7, 10)).Copy
                    Rows(Lrow & ":" & Lrow + 7).Copy wsRst.Range("3:10")
                   
                    End If   '<-----
                       
                End If

            End With

Thank you so much!!
 
Upvote 0

Forum statistics

Threads
1,215,098
Messages
6,123,082
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top