+ Reply to Thread
Results 1 to 4 of 4

How to copy cells with For Loops until a blank cell

  1. #1
    Registered User
    Join Date
    12-19-2020
    Location
    Turkey
    MS-Off Ver
    2019
    Posts
    19

    How to copy cells with For Loops until a blank cell

    Hi guys,

    I am new to VBA coding and trying to learn how to copy values in a column into another sheet but only until a blank cell is reached even if there is a formula with and iferror then blank ("") is in it.

    I believe for loops are perfect for this and something such as "if cell > 0" then... can be utilized to keep copying until a blank cell with formula in it is reached.

    So far I understand that something like x = x+1 in the loop can be used to loop through a range but I couldn't resolve to actually copying and pasting it in a new worksheet.

    I am attaching a sample workbook for you to maybe understand what I mean more clearly.

    Much appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: How to copy cells with For Loops until a blank cell

    Use 'Do While/Until' instead 'For Next'.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: How to copy cells with For Loops until a blank cell

    You are posting a .xlsx file, which has no code. So I don't know what you are trying to copy, from where, to where.

    In general to loop through a range and test if a cell is displaying a null string (even if it has a formula):

    Dim R As Row ' row number

    Please Login or Register  to view this content.
    There are other ways to do this, like finding the last row of data first, instead of testing for it in each row.

  4. #4
    Registered User
    Join Date
    12-19-2020
    Location
    Turkey
    MS-Off Ver
    2019
    Posts
    19

    Re: How to copy cells with For Loops until a blank cell

    Hi!

    If it would not be too much trouble could you please demonstrate with a code? You can use the sample workbook I att Like I said I am pretty new to VBA (like 2 weeks new) and don't quite know how to use functions that are new to me. Including the ones I mention in my original post

    If you cannot, thank you anyway for your help!

+ 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] Copy cell above to blank cells below till last filled cell of other column
    By abhinavbinkar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-31-2018, 05:59 AM
  2. VBA copy range of cells, paste on next blank cell down
    By ahalliwell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2018, 10:46 AM
  3. VBA if cell value = “no” then copy certains cells from same row to next blank row
    By millen182 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-04-2013, 04:35 PM
  4. Copy cell in below blank cells
    By graiggoriz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2012, 05:14 AM
  5. [SOLVED] Find first non-blank cell after a group of blanks copy offset cells, find next blank, loop
    By gwsampso in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2012, 06:11 AM
  6. [SOLVED] Copy cells to last non-blank cell
    By adam2308 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2012, 07:10 PM
  7. Replies: 4
    Last Post: 01-25-2011, 09:37 AM

Tags for this Thread

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