Results 1 to 5 of 5

Thread: VBA code does not perform any action

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Mar 2022
    Posts
    26
    Location

    VBA code does not perform any action

    Hello,
    I have a module with a code I have used several times in other sheets, a simple copy/paste. But for some reason I can't understand it just does not do anything. It doesn't return any error but it doesn't perform the instructed actions either.
    Help is appreciated.

    The code is as follows:
    Sub CopyPH()
    Dim wsc As Worksheet 'worksheet copy
    Dim wsd As Worksheet 'worksheet destination
    Dim lrow As Long 'last row of worksheet copy
    Dim crow As Long 'copy row
    Dim drow As Long 'destination row
    Set wsc = Sheets("1.2 Post Harvest Plan")
    Set wsd = Sheets("Consolidated Data")
    lrow = wsc.ListObjects("PostHarvest_Plan").Range.Columns(11).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    crow = 4
    drow = 4
    With wsc
    For crow = 4 To lrow 'starts at 4 because of the header row
    wsd.Cells(drow, 2).Value = .Cells(crow, 11).Value
    wsd.Cells(drow, 3).Value = .Cells(crow, 20).Value
    wsd.Cells(drow, 4).Value = .Cells(crow, 17).Value
    wsd.Cells(drow, 5).Value = .Cells(crow, 26).Value
    wsd.Cells(drow, 6).Value = .Cells(crow, 34).Value
    wsd.Cells(drow, 7).Value = .Cells(crow, 35).Value
    wsd.Cells(drow, 10).Value = .Cells(crow, 41).Value
    drow = drow + 1 'increasing the row in worksheet destination
    Next crow
    End With
    End Sub
    Last edited by SamT; 04-28-2022 at 02:56 AM.

Posting Permissions

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