Results 1 to 9 of 9

Copy range downwards till certain cell

Threaded View

  1. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Copy range downwards till certain cell

    Hi Jonathan78,

    There may be more elegant ways to do this, but this one should do the job.

    Try this:

    Sub main()
    
        Dim rngA As Range, rngB As Range
        Dim lRow As Long, lRowEnd As Long
    
        lRowEnd = 100        'change end row here
    
        With Sheets(1)
    
            Set rngA = .Range("B3", .Range("B" & Rows.Count).End(xlUp))
            Set rngB = .Range("D3", .Range("D" & Rows.Count).End(xlUp))
    
            lRow = rngA.Cells(1).Row
            Do
                lRow = lRow + rngA.Rows.Count
                .Cells(lRow, rngA.Column).Resize(rngA.Rows.Count, 1) = rngA.Value
            Loop While lRow < lRowEnd
    
            lRow = rngB.Cells(1).Row
            Do
                lRow = lRow + rngB.Rows.Count
                .Cells(lRow, rngB.Column).Resize(rngB.Rows.Count, 1) = rngB.Value
            Loop While lRow <= lRowEnd
    
            Application.Intersect(.Columns(rngA.Column), .Rows((lRowEnd + 1) & ":" & Rows.Count)).ClearContents
            Application.Intersect(.Columns(rngB.Column), .Rows((lRowEnd + 1) & ":" & Rows.Count)).ClearContents
    
        End With
        
        Set rngA = Nothing
        Set rngB = Nothing
    
    End Sub
    Last edited by berlan; 12-23-2013 at 05:05 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Search backward in range till empty cell
    By fedude in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-06-2013, 08:00 AM
  2. [SOLVED] VBA copy down till the specific coulmn range
    By vaibhav2312 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2013, 01:06 PM
  3. Replies: 3
    Last Post: 11-20-2012, 02:25 PM
  4. copy cell and paste diwn till last row
    By dingdang in forum Excel General
    Replies: 1
    Last Post: 09-24-2012, 01:22 PM
  5. copy till last used range
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-02-2012, 10:24 AM

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