+ Reply to Thread
Results 1 to 6 of 6

Join two VBA codes together

  1. #1
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Join two VBA codes together

    Hi all,

    Have been working with VBA a bit now, still a noob but learning everyday thanks to these forums.

    I simply have 2 codes that i want to assign to the same button, the first code is a kind of vlookup type copy and paste, and the second a output to pdf.

    I have tried joining together but keep getting errors. Any help be great. Please see codes below as two separate subs

    Please Login or Register  to view this content.
    What I need is to join these two subs together into one, I thought a "Then" function would have done this but to no avial

    Thanks in Advance

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Join two VBA codes together

    Either:
    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.

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

    Re: Join two VBA codes together

    Easiest way:
    Please Login or Register  to view this content.
    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...

  4. #4
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Re: Join two VBA codes together

    Hi All,

    Thanks for the quick replies, I was not familiar with the "Call" function, this will be very handy in the future.

    This is a bit off topic but my PDF code keeps returning an error saying "Document not Saved" as it points to the "OpenAfterPublish:=True" line

    I think the issue lies with my trying to reference cells as part of the filename

    Can you guys see anything obvious wrong with my code?
    Last edited by Simon.xlsx; 09-03-2014 at 10:51 AM.

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Join two VBA codes together

    Assuming you are calling one module from the other, sht1 might not be defined in your PDF sub, so it would need to be:
    Please Login or Register  to view this content.
    However, I think that would give you a different error to the one you mention, I would check that the filename is valid, and that the directory exists and you are able to write to it.

  6. #6
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Re: Join two VBA codes together

    Thanks all for your replies,

    The problem was indeed an invalid file name, I have sorted it now.

    Thanks again to all, Rep added

+ 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. Replies: 1
    Last Post: 12-10-2013, 12:28 AM
  2. Replies: 0
    Last Post: 10-09-2013, 07:59 PM
  3. [SOLVED] SQL Join - Left Join, but with 4 tables
    By kenny.fsw in forum Access Tables & Databases
    Replies: 4
    Last Post: 05-29-2013, 09:03 AM
  4. Join 2 UserForm_Activate codes into one
    By stojko89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-23-2011, 07:03 AM
  5. Join two codes together
    By MAButler in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2011, 12:50 PM

Tags for this Thread

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