+ Reply to Thread
Results 1 to 3 of 3

Copy / Paste macro giving errors

Hybrid View

  1. #1
    Registered User
    Join Date
    06-12-2008
    Posts
    29

    Copy / Paste macro giving errors

    I have a copy/paste macro and my copying range has some blank cells in it and some cells that are 0. When I paste the data it fills in the blank cells with 0's.

    Is there some code I can add so if the value is a zero it shows a zero and if the cell is blank it shows a blank?

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy / Paste macro giving errors

    To know how to approach this it would be useful to see your original copying code
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    06-12-2008
    Posts
    29

    Re: Copy / Paste macro giving errors

    This is my original code. Thanks

    Private Function GetValue(path, file, sheet, ref) 
         '   Retrieves a value from a closed workbook
        Dim arg As String 
         '   Make sure the file exists
        If Right(path, 1) <> "\" Then path = path & "\" 
        If Dir(path & file) = "" Then 
            GetValue = "File Not Found" 
            Exit Function 
        End If 
         '   Create the argument
        arg = "'" & path & "[" & file & "]" & sheet & "'!" & _ 
        Range(ref).Range("A1").Address(, , xlR1C1) 
         '   Execute an XLM macro
        GetValue = ExecuteExcel4Macro(arg) 
    End Function 
    Sub TestGetValue2() 
        p = "C:\Excel Test" 
        f = "Terry 2.xlsx" 
        s = "Sheet1" 
        a = "D6:G9" 
        Range("A1:D6") = GetValue(p, f, s, a) 
    End Sub

+ 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] Document copy and paste macro errors
    By glide2131 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2015, 03:57 PM
  2. VBA / Macro Copy & Paste errors
    By xlquestions in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2015, 03:00 PM
  3. VBA keeps giving errors on PasteSpecial
    By Inter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2012, 11:45 PM
  4. Copy/Paste Errors
    By Davidos15 in forum Excel General
    Replies: 3
    Last Post: 02-17-2009, 11:13 AM
  5. [SOLVED] Re: Range().resize giving errors
    By Harry Tuttle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2005, 02:35 PM
  6. [SOLVED] Macro giving errors at workbook open
    By kcdonaldson in forum Excel General
    Replies: 1
    Last Post: 12-06-2005, 12:20 PM
  7. [SOLVED] How avoid errors when you Copy chartobjects paste in powerpoint
    By Gunnar Johansson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2005, 08: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