简体   繁体   中英

Print labels vba

I have a worksheet that has the following

A1 xxx
A2 yyy
A3 zzz
B1 2
B2 5
B3 7

I would like to have a macro that enables me to print the value in cells A1 & cell B1 being the number of copies to print. I would like it to also loop through all the items in column A.

can't get it to work

Not sure I understand your question. But, from what you have posted, I think this is what you are trying to accomplish:

You have a spreadsheet that looks like this:

 A        B       C

1 xxx yyy zzz 2 2 5 7 3 aaa bbb ccc 4 9 4 6... 998 abc def ghi 999 8 2 3

And you want to manipulate some of the cells for empty cells and readjust the printout. Not sure a Macro will do that. That is something better suited for a program to accomplish. But, maybe that is not an option for you.

Now I am presuming that you want to print this out on laser labels with sizing like 1"x2-5/8" with 3 across and 10 down. You want your output to look like this:

xxx    yyy    zzz          aaa    bbb    ccc         ddd    eee   fff


 2      5      7            9      4      6            8     2     3

I presume this is your question? If so, here are the problems you are going to encounter:

  1. Labels were invented for the old days when Courier font was the de facto standard. Courier will print 6 lines to an inch, and 10 characters to an inch across. Labels came in different sizes and number of columns across. Today, labels are still being mfg to those standards. The Courier font is a fixed and non-scalable font. That means the letter "H" takes up the same space as the letter "i", and the font was not scalable.

  2. Most spreadsheets are scalable in the display and with printing. You can use Courier fonts in the cells, and that may help you. But, in the end, it will be like trying to mix oil and water.

  3. Your printer uses a grid to position items on the page. Most printers use HP's PCL language. For what you are doing, PCL5 will work fine. Most accounting applications use a grid of 300x300 for a cubic inch on the paper. So, if you position something to print at 150,150, it will print 1/2" down and across on the page. If you print something at 1500,300 on the page, it will print at 5" across the page and 1" down. The problem with a speadsheet is that spacing is fixed differently for each font size. This means that it will start printing correctly, and slowly drift off course. Note: Ignore that fact that your printer may be a 600 dpi or a 1200 dpi printer. For printing, you can set the dpi scale to different sizes. 300dpi for sizing (not resolution) is the standard for accounting.

Since this is most likely an accounting application, your office might have a Electronic Forms Software. That is the best route to accomplish your goals. EFS will bridge the gap between proportional data and place it in a fixed grid format with precision and ease.

You can also try to export it to Word and set it up to print to labels. Many word processors have the ability to print to labels.

What you are trying to do seems simple, the complexity of what happens between your spreadsheet and the printer is anything but simple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM