Cant find my error...

Hi i did try to figure out where i went wrong but i am not the best at this could some one assist me ?



-=-=-=-=-=-=-=-=-=-


ActiveWorkbook.Worksheets("Data").Activate

Dim LSearchRow As Integer
Dim LCopyToRow As Integer

LSearchRow = 2
LCopyToRow = 2

While Len(Range("A" & CStr(LSearchRow)).Value) > 0

If Range("C" & CStr(LSearchRow)).Value = 1 Then

Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy

Sheets("Status1").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.Paste


LCopyToRow = LCopyToRow + 1


For Column = 1 To 500
Sheets("Status1").Columns(Column).AutoFit
Next


Sheets("Data").Select

End If 'Closing of "Status1" If statement.

ActiveWorkbook.Worksheets("Data").Activate

Application.CutCopyMode = False


MsgBox "All matching data has been copied."

Exit Sub

Err_Execute:


If Err > 0 Then MsgBox "An error occurred, Error number: " & Err.Number & ": " & Err.Description


Exit Sub



-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


could some one help m,e please?

thank you

WaLaSy

Comments

  • Hi

    The while loop is not closed. Can you check if I have closed it (Wend) at the correct position

    [code]ActiveWorkbook.Worksheets("Data").Activate

    Dim LSearchRow As Integer
    Dim LCopyToRow As Integer

    LSearchRow = 2
    LCopyToRow = 2

    While Len(Range("A" & CStr(LSearchRow)).Value) > 0

    If Range("C" & CStr(LSearchRow)).Value = 1 Then

    Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
    Selection.Copy

    Sheets("Status1").Select
    Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
    ActiveSheet.Paste


    LCopyToRow = LCopyToRow + 1


    For Column = 1 To 500
    Sheets("Status1").Columns(Column).AutoFit
    Next

    Sheets("Data").Select

    End If 'Closing of "Status1" If statement.

    ActiveWorkbook.Worksheets("Data").Activate

    Application.CutCopyMode = False

    Wend
    MsgBox "All matching data has been copied."

    Exit Sub

    Err_Execute:

    If Err > 0 Then MsgBox "An error occurred, Error number: " & Err.Number & ": " & Err.Description

    Exit Sub



    End Sub[/code]

    : Hi i did try to figure out where i went wrong but i am not the best
    : at this could some one assist me ?
    :
    :
    :
    : -=-=-=-=-=-=-=-=-=-
    :
    :
    : ActiveWorkbook.Worksheets("Data").Activate
    :
    : Dim LSearchRow As Integer
    : Dim LCopyToRow As Integer
    :
    : LSearchRow = 2
    : LCopyToRow = 2
    :
    : While Len(Range("A" & CStr(LSearchRow)).Value) > 0
    :
    : If Range("C" & CStr(LSearchRow)).Value = 1 Then
    :
    : Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
    : Selection.Copy
    :
    : Sheets("Status1").Select
    : Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
    : ActiveSheet.Paste
    :
    :
    : LCopyToRow = LCopyToRow + 1
    :
    :
    : For Column = 1 To 500
    : Sheets("Status1").Columns(Column).AutoFit
    : Next
    :
    :
    : Sheets("Data").Select
    :
    : End If 'Closing of "Status1" If statement.
    :
    : ActiveWorkbook.Worksheets("Data").Activate
    :
    : Application.CutCopyMode = False
    :
    :
    : MsgBox "All matching data has been copied."
    :
    : Exit Sub
    :
    : Err_Execute:
    :
    :
    : If Err > 0 Then MsgBox "An error occurred, Error number: " &
    : Err.Number & ": " & Err.Description
    :
    :
    : Exit Sub
    :
    :
    :
    : -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    :
    :
    : could some one help m,e please?
    :
    : thank you
    :
    : WaLaSy
    :

    VBA Tips & Tricks ([link=http://vbadud.blogspot.com]http://vbadud.blogspot.com[/link])

    C# Code Snippets ([link=http:dotnetdud.blogspot.com]http:dotnetdud.blogspot.com[/link])
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion