+ Reply to Thread
Results 1 to 11 of 11

for loop listing without empty cells

  1. #1
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    2016 professional
    Posts
    148

    for loop listing without empty cells

    Dear Pros,


    Can anyone help me pointing to the mistake in my code?


    I want to list the entries from sheet 2 to sheet 1 without any empty cells in between them.

    If i run the Code as it is, it keeps listing just the last entry.
    If I update lastrow2 it keeps listing all the entries but with empty cells between them..


    Can anyone modify it to work properly? (with as litte Change as possible to be able to see what I was doing wrong)


    Thank you indeed for your help!


    Best regards
    Peter
    Attached Files Attached Files

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: for loop listing without empty cells

    Hi,

    Try this out

    Please Login or Register  to view this content.
    Cheers!
    Deep Dave

  3. #3
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    2016 professional
    Posts
    148

    Re: for loop listing without empty cells

    Thank you for your answer NeedForExcel

    I am not that far with Arrays..and I will Need to adopt it to other Sheets. Can you Maybe tell me how to alter my existing Code?

    I know it is not that elegant or Fancy as yours

    thank you indeed!

  4. #4
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,008

    Re: for loop listing without empty cells

    Can anyone modify it to work properly? (with as litte Change as possible to be able to see what I was doing wrong)
    Please Login or Register  to view this content.

  5. #5
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: for loop listing without empty cells

    Quote Originally Posted by peterschein View Post
    I am not that far with Arrays..and I will Need to adopt it to other Sheets. Can you Maybe tell me how to alter my existing Code?
    You can try out the code given by Akuini, that should serve the purpose..

  6. #6
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    2016 professional
    Posts
    148

    Re: for loop listing without empty cells

    end if…

    thank you!!!

  7. #7
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    2016 professional
    Posts
    148

    Re: for loop listing without empty cells

    Dear NeedForExcel Dear Akuini


    If I apply it to the final Code I get a warning that there is an end if without the if bock... do you know why?

    if I comment the "End If" out, I got the list but with gaps in between..

    can you help?

    Please Login or Register  to view this content.

  8. #8
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: for loop listing without empty cells

    In the case of only constant in the source
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,008

    Re: for loop listing without empty cells

    Try:
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    2016 professional
    Posts
    148

    Re: for loop listing without empty cells

    Quote Originally Posted by Akuini View Post
    Try:
    Please Login or Register  to view this content.
    wow I didn´t know that it makes any difference how I brake the lines.


    but it works!

    thank you!!

  11. #11
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,008

    Re: for loop listing without empty cells

    You're welcome, glad to help, & thanks for the feedback.

+ 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. [SOLVED] Loop That Will Count Number Of Comments In a Column Between Empty Cells
    By M7A0S8T8E5R in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2016, 04:32 PM
  2. [SOLVED] loop through a coulmn to test is a cells is empty
    By deek in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-04-2016, 03:48 PM
  3. Replies: 2
    Last Post: 08-13-2013, 06:06 AM
  4. [SOLVED] How to write loop to check for empty cells
    By JaydenK in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-22-2013, 09:17 AM
  5. Loop through groups of rows separated by empty cells
    By wmbower in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2012, 02:53 PM
  6. Listing Items Without Empty Cells
    By hjlewallen in forum Excel General
    Replies: 3
    Last Post: 11-12-2011, 07:17 AM
  7. [SOLVED] Empty cells in For Loop
    By Linking to specific cells in pivot table in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2005, 03: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