+ Reply to Thread
Results 1 to 3 of 3

Put Existing Functions in VBA Code

  1. #1
    Registered User
    Join Date
    01-26-2015
    Location
    Massachusetts
    MS-Off Ver
    2016
    Posts
    73

    Put Existing Functions in VBA Code

    Hello Everyone,

    VBA Newbie using Excel 2013.

    I've created a worksheet ("To Database") that has several columns containing functions that refer to cells in another worksheet ("Payment_Type_D"). I would like to create a sub routine that a user can run that will create this new worksheet ("To_Database") and have the data fill based on these functions. I have the VBA code to create the new sheet, but don't know how to insert the functions.

    The data will be used as a csv feed into a larger database. The database requires two records (rows) per gift payment numbered 01 and 02. We could have up to 50 gifts with two rows per gift.

    Any help to get me started would be greatly appreciated. Sample file attached.

    Thank you!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Put Existing Functions in VBA Code

    hi wwconslt, these rows are strange - it is generally inadvisable to have two different datatypes per column, and also i'm not really following why some of those columns are labeled as they are... "Gift Code" returns a credit card type? Campaign ID and Gift Desig both return the same exact value... called Desig Code on 'Payment_Type_D'...?

    anyway, i'd highly recommend turning those 3 columns (E:G) into 6 columns so you can avoid the data-mismatch within a given column.

    but, your ask was around inserting functions, for which the code is:

    Please Login or Register  to view this content.
    ActiveCell can (and probably should) be replaced with a variable you've declared up front, and based on your dataset i'm guessing you really want your code to look something like this:

    Please Login or Register  to view this content.
    Hope I could help - if your post has been solved don't forget to mark it as such.

    Clicking the * below is a great way to say thanks!

    "Drowning in 10 feet of water isn?t any different than drowning in a million feet. And if you can swim, it doesn?t matter how deep the ocean is. At some level, once you realize you?re in water that?s too deep to stand, you have to have a very different approach," - Joi Ito

  3. #3
    Registered User
    Join Date
    01-26-2015
    Location
    Massachusetts
    MS-Off Ver
    2016
    Posts
    73

    Re: Put Existing Functions in VBA Code

    Hi Simarui,

    Thanks so much for this excellent solution--it works perfectly! I agree that the mix of data types in columns is odd. But that's the exact structure and format the vendor requires. They want the resulting csv file to look like this:

    000000001,4001,01,10,Visa,4/20/2015,,
    000000001,4001,02,020000,025100,10,,
    000000002,4002,01,60,Visa,4/20/2015,,
    000000002,4002,02,020000,025200,60,,

    But in any case, your solution works great. Thanks again!

+ 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] VBA code to save current worksheet as temporary PDF file and then add to my existing code
    By brianfromla in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-20-2014, 08:35 AM
  2. Replies: 2
    Last Post: 12-17-2013, 11:51 AM
  3. [SOLVED] Correct way to apply an existing VBA code to an existing sheet
    By JO505 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 05:42 PM
  4. Replies: 2
    Last Post: 03-17-2011, 08:55 PM
  5. Replies: 1
    Last Post: 08-15-2009, 05:52 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