+ Reply to Thread
Results 1 to 5 of 5

VBA: copy range from sheet1 to sheet2 but deleting zeros

  1. #1
    Forum Contributor
    Join Date
    04-21-2012
    Location
    rome, italy
    MS-Off Ver
    365
    Posts
    131

    VBA: copy range from sheet1 to sheet2 but deleting zeros

    i have to copy a range from sheet1 to sheet2 (so to have text in sheet2 cells, while in sheet1 cells there are formulas)

    but empy cells in sheet1 generate "0" in equivalent cells in sheet2.

    Sheets("sheet1").Range("A2:G10000").Copy
    Sheets("sheet2").Range("A2:G10000").PasteSpecial Paste:=xlPasteValues

    how can i copy it so that sheet1 empty cells remain empty also in sheet2?

  2. #2
    Forum Contributor
    Join Date
    04-21-2012
    Location
    rome, italy
    MS-Off Ver
    365
    Posts
    131

    Re: VBA: copy range from sheet1 to sheet2 but deleting zeros

    i tried to insert after the paste:

    Sheets("sheet2").Select
    Range("A2:G10000").Select
    For Each Cell In Selection
    If Cell.Value = 0 Then
    Cell.Value = ""
    End If
    Next

    but it needs several seconds to scan thousands of cells (they are 70.000 cells = seven columns, each one 10.000 cells).

    is there another way?
    Last edited by vermaccio; 01-20-2022 at 09:48 AM.

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: VBA: copy range from sheet1 to sheet2 but deleting zeros

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Forum Contributor
    Join Date
    04-21-2012
    Location
    rome, italy
    MS-Off Ver
    365
    Posts
    131

    Re: VBA: copy range from sheet1 to sheet2 but deleting zeros

    fantastic! thank you

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: VBA: copy range from sheet1 to sheet2 but deleting zeros

    You are very welcome.

+ 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. extractin data from sheet1 into sheet2+adding&deleting rows in sheet1
    By xxl2953 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-18-2016, 05:05 AM
  2. Replies: 6
    Last Post: 07-25-2013, 02:58 PM
  3. Replies: 4
    Last Post: 03-17-2013, 05:58 AM
  4. Replies: 0
    Last Post: 01-16-2013, 07:46 PM
  5. [SOLVED] Copy Range from Sheet2 to Sheet1 through VBA
    By FallingDown in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-29-2012, 02:56 AM
  6. VBA Coding to copy range data from sheet1 to sheet2
    By kenadams378 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-29-2012, 06:02 AM
  7. Macro to copy range of cell from sheet1 to sheet2 based on a cell value in sheet2
    By drgwhizz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-25-2012, 10:39 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