+ Reply to Thread
Results 1 to 7 of 7

Printing selected items as a form - editing the macro

Hybrid View

  1. #1
    Registered User
    Join Date
    09-29-2007
    Posts
    5

    Printing selected items as a form - editing the macro

    Hi there,

    I am new to macros, so please bear with me. I am not used to editing the codes, and I am unfamiliar with the slang. So far, I am doing my best... here goes my question.

    I wanted to print specific information into an invoice. I found a code to use... I copied this code from this site:

    http://www.contextures.com/xlForm03.html

    It works fine, but I would like to tailor it a bit. Can someone suggest a way for me to a)use "p" instead of "x" as the data indicator; b)change the range so that I can use specific cells in a row, instead of ALL cells in a row.

    Thank you. I hope that I made enough sense for you =)

    Best

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    As written, anything can be used to "mark a row".

    This line details where data is put into the form/worksheet to be printed.
    myAddresses = Array("E5", "E6", "B10", "E25", "B16", "C16", "D16")
    As written, the code puts the first 7 values on a marked row into that output sheet. If you want to control which columns on a marked row go to the output sheet.

    Add
    Dim myInputColumns as Variant:Rem this line can go at the start of the routine.
    myInputColumns = Array(1,2,3,4,5,6,7)
    immediatly after the myAddresses line.
    And change the line to this:
    For iCtr = LBound(myAddresses) To UBound(myAddresses)
                        FormWks.Range(myAddresses(iCtr)).Value _
                            = myCell.Cells(1,myInputColumns(iCtr)).Value
    By changing the 1,2,3,..,7 to the columns you want, you will get the control you want. Make sure that the myInputColumns is as large (or larger than) the myAddress array.

  3. #3
    Registered User
    Join Date
    09-29-2007
    Posts
    5
    Amazing! Thank you

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    You're welcome

  5. #5
    Valued Forum Contributor
    Join Date
    01-02-2004
    Location
    malaysia
    Posts
    342
    Hi mikerickson,
    I am new to macro coding but I seek your help in explaining the following:-
    'cells to copy from Input sheet - some contain formulas
    myCopy = "D5,D7,D9,D11,D13"

    what is D5,D7,D9.......? what does it represent? If I want to copy more columns,how do I do it,Thanks a million

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I can't find that quote in any of the references in this thread. (Unless it is from the contexures link in the OP, other users of this forum would benifit more if this discussion were its own thread.

    If it is code, then
    'cells to copy from Input sheet - some contain formulas
    myCopy = "D5,D7,D9,D11,D13"
    The apostrophy at the start of the first line indicates that that line is a comment.
    The next line sets the variable myCopy to the string "D5,D7,D9,D11,D13"

    I would need to see the rest of the code to tell you how it fits together.

    Since those cell addresses are all in the same column, we definatly would need to see the code to make it work on more than column D.

    Please start a new thread. If you post the code in that thread, please wrap it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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