Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    for HansV because it know my problem (2000 sr 1)

    my dear remember this routin you have maked for me...

    Sub ASS_CONT_A_CDI50()

    Dim lngSourceRow As Long
    Dim lngSourceMaxRow As Long
    Dim lngTargetRow As Long
    Dim wshSource As Worksheet
    Dim wshTarget As Worksheet

    On Error GoTo ErrHandler

    Application.ScreenUpdating = False

    ' Set reference to worksheets
    Set wshSource = Worksheets("L0785_TOTALE")
    Set wshTarget = Worksheets("L0785_CDI_50")
    ' Last row in source sheet
    lngSourceMaxRow = wshSource.Range("A65536").End(xlUp).Row
    ' Last row in target sheet
    lngTargetRow = wshTarget.Range("A65536").End(xlUp).Row
    ' Loop backwards through source rows
    For lngSourceRow = lngSourceMaxRow To 7 Step -1
    ' Test condition
    If wshSource.Range("T" & lngSourceRow) = "ASS. CONT. A CDI 50" Then
    ' Next target row
    lngTargetRow = lngTargetRow + 1
    ' Copy to target sheet
    wshSource.Rows(lngSourceRow).Copy wshTarget.Rows(lngTargetRow)
    ' Delete from source sheet
    wshSource.Rows(lngSourceRow).Delete
    End If
    Next lngSourceRow

    ExitHandler:
    Set wshSource = Nothing
    Set wshTarget = Nothing

    Application.ScreenUpdating = False

    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler

    End Sub

    ok! but when the macro make a copy in the sheet is possoble to copy only the range A:T and not the entire line in the sheet L0785_CDI_50?

    Mnay tks...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: for HansV because it know my problem (2000 sr 1)

    Replace the line

    wshSource.Rows(lngSourceRow).Copy wshTarget.Rows(lngTargetRow)

    by

    wshSource.Range(wshSource.Cells(lngSourceRow, 1), wshSource.Cells(lngSourceRow, 20)).Copy wshTarget.Cells(lngTargetRow, 1)

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: for HansV because it know my problem (2000 sr 1)

    as usual , tks....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •