+ Reply to Thread
Results 1 to 3 of 3

Dynamic Ranges of Rows Cont'd

  1. #1
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Dynamic Ranges of Rows Cont'd

    Hello Again,

    Recently, member Millz just helped me update code based on a dynamic range of cells, which worked! I want to drop a csv file into one sheet, and copy the data to another sheet. However, if I drop a new csv file in, and there are fewer rows, the old rows aren't deleted. For example, if my first set of data had 10 rows, and the new has 8, the extra two rows are still there. How do I deal with this?

    [code]
    With Sheets("Raw Data")
    .Range("A10", .Range("A" & Rows.Count).End(xlUp)).Copy ActiveSheet.Range("A12")
    .Range("B11", .Range("B" & Rows.Count).End(xlUp)).Copy ActiveSheet.Range("B12")
    .Range("E11", .Range("E" & Rows.Count).End(xlUp)).Copy ActiveSheet.Range("C12")
    .Range("F11", .Range("F" & Rows.Count).End(xlUp)).Copy ActiveSheet.Range("D12")
    .Range("H11", .Range("H" & Rows.Count).End(xlUp)).Copy ActiveSheet.Range("E12")
    End With
    [\code]

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Dynamic Ranges of Rows Cont'd

    To remove all the existing data, before "dropping in a new csv" file. Try

    Cells.ClearContents
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Dynamic Ranges of Rows Cont'd

    Thank you! I initially was using DeleteColumn, bad idea, ruined everyt

+ 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. How to loop through dynamic ranges using columns rather than rows
    By xcelnovice101 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-24-2014, 06:28 PM
  2. name dynamic ranges with VBA
    By robotlust in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2008, 01:04 PM
  3. how to do a dynamic ranges?
    By MadCow in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-05-2006, 09:13 AM
  4. Dynamic Formulas with Dynamic Ranges
    By Ralph Howarth in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-21-2005, 05:06 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