Results 1 to 4 of 4

Thread: How to do End(xlUp).Row + 1 using a loop in VBA
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jan 2015
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default How to do End(xlUp).Row + 1 using a loop in VBA

    HI. So I am using a loop to move data from one sheet to another but there are 3 sheets in all. I need it to look up each sheet before it moves data over to only paste in a blank cell.

    Currently my macro is as follows

    Rc = 2
    For p = 1 To 3
    For i = 5 To 3000
    With Sheets("Data")
    If Sheets("Data").Range("A" & i).Value = "" Then GoTo next_i
    If Sheets("Data").Range("M" & i).Value = Sheets("Lookup").Range("P" & p).Value Then
    Worksheets(Sheets("Data").Range("M" & i).Value).Range("A" & Rc).Value = Sheets("Data").Range("A" & i).Value

    However I want Rc to be the end of the row on the individual tabs as the information is always in different rows.

    Please help!!!

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,228
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: How to do End(xlUp).Row + 1 using a loop in VBA

    How about
    Code:
    For p = 1 To 3
       For i = 5 To 3000
          With Sheets("Data")
             If .Range("A" & i).Value = "" Then GoTo next_i
             If .Range("M" & i).Value = Sheets("Lookup").Range("P" & p).Value Then
                Worksheets(.Range("M" & i).Value).Range("A" & Rows.Count).End(xlUp).Offset(1).Value = Sheets("Data").Range("A" & i).Value
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    New Member
    Join Date
    Jan 2015
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to do End(xlUp).Row + 1 using a loop in VBA

    You Legend Fluff!!!!

    Thanks so much!

    Quote Originally Posted by Fluff View Post
    How about
    Code:
    For p = 1 To 3
       For i = 5 To 3000
          With Sheets("Data")
             If .Range("A" & i).Value = "" Then GoTo next_i
             If .Range("M" & i).Value = Sheets("Lookup").Range("P" & p).Value Then
                Worksheets(.Range("M" & i).Value).Range("A" & Rows.Count).End(xlUp).Offset(1).Value = Sheets("Data").Range("A" & i).Value

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,228
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: How to do End(xlUp).Row + 1 using a loop in VBA

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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