+ Reply to Thread
Results 1 to 5 of 5

Optimizing already available macro by fixing run time errors

  1. #1
    Registered User
    Join Date
    07-14-2016
    Location
    Bangalore, India
    MS-Off Ver
    2013
    Posts
    28

    Optimizing already available macro by fixing run time errors

    Hello,

    I've written this macro to -

    1. Copy the data from cell B17
    2. Open an existing document on my computer.
    3.Paste it in the existing document.
    4. Save the document as a pdf.

    ****************************************************
    Please Login or Register  to view this content.
    **********************************************************
    It is also throwing a few run-time errors like - Run time error 13 (Type mismatch) for Ln17.

    Could you please help me achieve this?

    Regards,
    Anshul
    Attached Files Attached Files
    Last edited by anshul1719; 07-18-2016 at 07:29 AM.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Optimizing already available macro by fixing run time errors

    Edit: code tags added to original post
    Last edited by Olly; 07-18-2016 at 07:32 AM.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    07-14-2016
    Location
    Bangalore, India
    MS-Off Ver
    2013
    Posts
    28

    Re: Optimizing already available macro by fixing run time errors

    Sorry about that, have updated it!

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Optimizing already available macro by fixing run time errors

    You should get in the habit of explicity declaring variables. In this case, if you declare str1 as a string, it will prevent the "Type mismatch" error:
    Please Login or Register  to view this content.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Optimizing already available macro by fixing run time errors

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

+ 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] Need Help Optimizing Macro
    By calebjcook in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2015, 11:08 PM
  2. [SOLVED] CF for time difference - fixing formula
    By Lukael in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 07-27-2014, 05:00 PM
  3. [SOLVED] Need help fixing a formula, currently returning errors and dont know how to fix it
    By 33CDonnelly in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-15-2013, 04:17 PM
  4. Optimizing code time running
    By Pichingualas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-02-2012, 12:13 PM
  5. Fixing time formats and converting hh:mm to mm:ss
    By AG65 in forum Excel General
    Replies: 2
    Last Post: 02-09-2012, 04:39 PM
  6. Optimizing Excel macro to find/replace with the list of data contained in the macro
    By Iceyburnz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2008, 08:41 PM
  7. Undo fixing cells with formula errors.
    By josnah in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-16-2008, 07:21 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