+ Reply to Thread
Results 1 to 3 of 3

Rows copying from bottom to top. need to copy top to bottom.

Hybrid View

  1. #1
    Registered User
    Join Date
    05-27-2015
    Location
    Florida, US
    MS-Off Ver
    2013
    Posts
    33

    Rows copying from bottom to top. need to copy top to bottom.

    Good Morning everyone,

    currently im working with a list "test". In this list im searching for keywords and then having it copy over to a specific sheet. The problem im encountering is that it is copying the rows over from bottom to top. not top to bottom. I want it to search for jimmy from top to bottom and copy the rows over as it finds it. I guess right now its searching from bottom to top and copying them but im not sure how to change that.

    Sub testing()
    
    If ActiveSheet.Name = "test" Then 'This is saying to run the code if the Daily sheet is active, otherwise msgbox will pop up
    
    Application.ScreenUpdating = False
    
      Sheets("jimmy").Select 'Calling the erase all sub below
      activewindow.Zoom = 85
          With activewindow
            .SplitColumn = 0
            .SplitRow = 1
        End With
        activewindow.FreezePanes = True
        Call Sizecolumns
        Call eraseAll
    
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim wsjimmy As Worksheet
    
    Set wb = Application.ThisWorkbook
    Set ws = Sheets("test")
    Set wsjimmy = Sheets("jimmy")
    
    LastRow = ws.Cells(Rows.Count, "K").End(xlUp).Row
    lrjimmy = wsJimmy.Cells(Rows.Count, "K").End(xlUp).Row
    
    With ws
    
    For lng = LastRow To 2 Step -1
    
         If Range("K" & lng).Value = "Jimmy" Or Range("K" & lng) = "JIMMY" Or Range("K" & lng) = "jimmy" Then
            Rows(lng).Copy Destination:=wsjimmy.Range("A" & lrjimmy + 1)
            lrJose = lrJose + 1
                ElseIf Range("K" & lng).Value = "J" Or Range("K" & lng) = "j" Or Range("K" & lng) = "jim" Or Range("K" & lng) = "Jim" Or Range("K" & lng) = "immy" Then
                MsgBox "At least one result starting with 'J' was omitted while looking for 'jimmy'" & vbNewLine & "please look for possible typos in Column K"
        End If
        
    Next lng
    
    End With
    End If
    Application.ScreenUpdating = True
    MsgBox "Processing Complete."
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Rows copying from bottom to top. need to copy top to bottom.

    For lng = LastRow To 2 Step -1
    
    TO
    For lng =  2 to LastRow

  3. #3
    Registered User
    Join Date
    05-27-2015
    Location
    Florida, US
    MS-Off Ver
    2013
    Posts
    33

    Re: Rows copying from bottom to top. need to copy top to bottom.

    Perfect! Thank you very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Draw bottom border on every rows from top to bottom
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2013, 09:52 AM
  2. Replies: 2
    Last Post: 12-18-2012, 05:22 AM
  3. Copy and insert new row 5 rows up from bottom of sheet
    By xned in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2009, 03:13 AM
  4. Shared Top and Bottom Border - Bottom not printing
    By bick421 in forum Excel General
    Replies: 0
    Last Post: 01-07-2009, 03:47 PM
  5. a macro that will copy rows 4 through 10 and add them to the bottom
    By 2newguy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-10-2007, 03:10 AM
  6. Replies: 1
    Last Post: 04-09-2006, 04:30 PM
  7. Copying formula to the bottom of a range
    By jeremy nickels in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2005, 04:06 PM
  8. Replies: 1
    Last Post: 01-24-2005, 09:06 PM

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