+ Reply to Thread
Results 1 to 19 of 19

user form to fill in data into specific cells

  1. #1
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    user form to fill in data into specific cells

    Hi, Im new to word macro and would like help on this.

    Attached is the word document that needs macro codes. It is a template for printing on 13mm round stickers. What i hope to have is a user form that will help user enter data into specific cells in the table and print onto the sticker. The information to be printed will be like this:

    1234
    001 - 20uL
    RSID

    each cell will have slightly different information, so copy and pasting is not going to cut it.
    One user will not be able to use up the whole sheet of labels on his own, so the next user will carry on from where he left off. The user form must be able to let the user decide where the information goes, if not it will b a disaster if they printed on the space where the sticker has already been removed.

    Hope somebody can help me with this

    Oh and another thing, is it possible to have the info on the first row to duplicate itself on the second row, third row info duplicate itself on fourth row etc etc?
    Attached Files Attached Files
    Last edited by bqheng; 05-20-2014 at 02:24 AM.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    Instead of a userform, I'd suggest inputting the raw data into an Excel workbook (one row per sticker) and using a label mailmerge to output the data to the sticker sheet. By varying the number of empty rows in the Excel workbook, you can control where on the sticker sheet the output starts.

    Trying to control all this via a userform is far more difficult than using a mailmerge.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    hi macropod, would you be able to help me with this? I don't know much about mailmerge or how to go about the excel file

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    From the description in your first post, you'd set up an Excel workbook with three columns, one for each row on the label. Each of these columns would have a header row. I have no idea what the three values in your example represent but you might, for example have headers named 'ID', 'Tag' and 'Code', respectively. Having input the data, you'd save the workbook and start a label mailmerge from Word. For outlines of that process, see:
    http://word.mvps.org/FAQs/MailMerge/...AMailMerge.htm
    http://office.microsoft.com/en-us/wo...101857701.aspx

    Next time you want to print some labels, simply re-open the workbook, edit the data (including inserting however many empty rows you need to start the next print at the first unused label), save the workbook, then re-open the same malmerge document you used last time and execute the merge.

  5. #5
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    Hi macropod, was playing around with what you suggested and found it to be alittle troublesome to have 2 files for mail merge. I made a userform in Word but need some help in the coding.

    In the first half of the code you will see that i used bookmarks to link each cell in the table to a textbox on the userform. The code concatenates the textbox value with additional info at the back. Can you help me with coding something? If the textbox is left blank, I do not want the concatenated info to appear on the table. I tried If / Then / Else, but i think i got the coding wrong and it doesn't work.

    Hope you can help me with this
    Attached Files Attached Files

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    Why on earth would you bother with all that work when the user can just as easily have all the '-20ul RSID' etc. data already in the table and just enter the prefix data there and format the unwanted cells with the hidden text format?

    Also, why all the bookmarks? You can address the cells directly, via their row/column references? With that, you could reduce your code to:
    Please Login or Register  to view this content.
    where the userform textbox names are R01C01, R01C03, etc. That will take care of not outputting to empty cells also. Of course, you also need a lot more textboxes on your userform to cater for all the cells on the page - you presently cater for only 1/4 of them.

  7. #7
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    Hi thank you for your reply. I changed the codes to the one you provided but there is an error highlighting
    If Me.Controls("R" & Format(r, "00") & "C" & Format(c, "00")).Value <> "" Then

    I changed all the textbox names to R01C01 etc etc.

    Row 1 info will duplicate onto row 2, thats why i only created that many rows in the userform. Can you help me with that code also?

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    Try:
    Please Login or Register  to view this content.
    Note: The userform textboxes need to be named:
    R01C01 R01C02 R01C03
    R02C01 R02C02 R02C03
    R03C01 R03C02 R03C03
    etc.

  9. #9
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    still have the error. just a quick check, will it matter if i named the textboxes like this:
    R01C01 R01C02 R01C03
    R03C01 R03C02 R03C03
    R05C01 R05C02 R05C03
    etc

    as info from row 1 will duplicate into row 2, so does that mean i can skip R02C01 etc?
    Attached Files Attached Files

  10. #10
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    Yes, it matters. With the revised code the userform textboxes need to be named:
    R01C01 R01C02 R01C03
    R02C01 R02C02 R02C03
    R03C01 R03C02 R03C03
    etc., not:
    R01C01 R01C02 R01C03
    R03C01 R03C02 R03C03
    R05C01 R05C02 R05C03
    etc.

    I realise its a pain to have to rename them, but you can avoid renaming half of them by moving rows of textboxes up/down.

  11. #11
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    Hi, the userform works now, but there is a problem. The information in the 5 columns onwards only reflect 1ul PSA instead of all 4 wordings to be concatenated.

    Can you help me with this?
    Attached Files Attached Files

  12. #12
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    Change:
    Select Case c - 1 Mod 8 + 1
    to:
    Select Case (c - 1) Mod 8 + 1

  13. #13
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    Thank you macropod. Another question:
    I'm thinking of shrinking down the form further by reducing columns.
    since the info before the concatenate wordings in row 1 columns 1 to 4 are the same, can we do the same duplication code used to duplicate row 1 to row 2, but now is to duplicate the unconcatenated words from column 1 through 4, columns 5 to 8 and columns 9 to 12?

  14. #14
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    If you reduce the column count on the userform, how will you prevent extra labels being printed on the replicated columns when you don't want them? If you reduce the columns on the userform to 4, the replication means the minimum number of labels you'll get is 6.

  15. #15
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    Alright, since it's not possible then it's ok
    How do I add a button to call out the userform after i close it?

  16. #16
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    Simply copy your 'Execute' button, change it's caption to 'Close' and add another sub to your userform like:
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    oh, what i meant was how do i add a button somewhere on the word document to call out the userform if somebody accidentally close it before they finish inoutting the info

  18. #18
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,835

    Re: user form to fill in data into specific cells

    Your could add a macrobutton field below the table, coded as: {MACROBUTTON Document_Open Double-Click here to reload form}
    You will also need to delete the 'Private' before 'Private Sub Document_Open()'.

    Note: The field brace pairs (i.e. '{ }') for the above example are created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message.

  19. #19
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    361

    Re: user form to fill in data into specific cells

    Thank you macropod for your help, I have learnt alot from you

+ 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. user form to fill in data into specific cells
    By bqheng in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-27-2014, 07:57 PM
  2. Fill cells determined by Time Value selection w/user form
    By ShannonHowell in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 09:56 PM
  3. Create User form to pull from equipment list and fill in data
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2009, 02:48 PM
  4. [SOLVED] Using Button on User Form to save Data to specific Cell??
    By DarnTootn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2006, 10:25 AM
  5. Retrieving Data from a worksheet to auto fill a user form
    By mg_sv_r in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2006, 06:15 PM

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