Results 1 to 9 of 9

Thread: VBA and macros for filling data and printing in the tables

  1. #1

    VBA and macros for filling data and printing in the tables



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi again.
    I have a really tough problem.

    As you can see, I have 2 worksheets. I want that all entries in columns B,D,E and F automaticly fill in in multiple tables in sheet2.
    Also, if possible that macro creates tables (for example: if I have 100 rows, I want to extract 100 separetly values from column B,D,E and F and to enable automatic creation for new table - for 101 entry )

    So, I want when I click on the button I want to automaticly import all mentioned values into sheet 2 (I have marked with RED where to put values from which column). In this example, I expect, when I clik on Print all tables button, to print 7 tables in sheet2.
    In sheet2 I have 2 tables as you can see.

    I cannot give you the link of the file, beaceuse Im new
    Any ideas? Thanks!

  2. #2
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,478
    Articles
    0
    Excel Version
    365
    Quote Originally Posted by cvelle89 View Post
    Hi again.
    …but this is your first post here!

    For others considering responding, be aware that this has been cross-posted in at least 2 other places and there have been responses at one of those.

    cvelle89, please provide links to where you have cross-posted and have a quick read of: http://www.excelguru.ca/content.php?184

  3. #3
    Dear p45cal,
    First of all sorry for this "Hi again".
    I was in the hurry to complete my task at work.

    There's only 2 places (including this forum) where I asked for help. At the another forum, I didnt get an answer. I think I didnt do anything wrong. Because nobody answered me there.

    Because I am working, I am wondering do you receive donations?
    I just started to expose my "problems" in excel (I want to do it faster, cleaner, and simpler) Thanks.

    I can not provide any links cause I dont have 5 or more posts....

  4. #4
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,478
    Articles
    0
    Excel Version
    365
    donations? I'm no moderator here.
    re links, just paste the links but scrub the http:// or www parts, people will understand.

    No, you didn't get responses, they were your own responses - sorry.
    Here are the links to your other posts:
    http://www.excelforum.com/excel-prog...-printing.html
    http://stackoverflow.com/questions/2...a-and-printing

    and a copy of the link to your file:

    https://www.dropbox.com/s/iiaewngq8j...0ispravka.xlsm

  5. #5
    Ok, I did not get answer there so I dont understand what is a big deal?

    Thanks for copying instead of me, I appreciate it.

    Back to topic.
    I came to the solution but it's not pretty. I ran a macro for each row, to copy values from B,D,E columns to the next sheet where I want it. A big headache is the merged cells... so for now its working, and for each row I have a button with a macro.
    It's doing the job, but I want it cleaner solution.

    Thanks

  6. #6
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,478
    Articles
    0
    Excel Version
    365
    Quote Originally Posted by cvelle89 View Post
    Ok, I did not get answer there so I dont understand what is a big deal?
    When I have spent time (half an hour? 1 hour? 2 hours?) helping someone (for free) and later discover that he already had a solution several hours, or days ago, elsewhere, I have wasted my time - utterly.
    I'm one of those responders who will now check for cross posts, and if the person asking the question still cross posts (with another question) without linking to all cross posts at all the forums or ignores requests to post links, I simply ignore him, now, and in the future. I won't be the only one who does this. Anyway, all this is clearly laid out in the article:http://www.excelguru.ca/content.php?184 . Read it, it will be to your benefit.
    I would expect you to put links to here in both your other threads so that if someone does see an unanswered thread at stackoverflow or MrExcel, they will be able to check all sites to see whether he can improve on other's solutions, or simply see that your problem has been solved.

    You're not alone, when I first started posting questions at forums, I too cross-posted without providing links!
    Enough of that.

    Since you seem to have 2 forms per sheet, what if you updated 1 sheet with 2 rows of data, printed that, updated the 2 forms with the next two rows, print that sheet, etc.?
    See attached to get you started.
    The macro in there is:
    Code:
    Private Sub CommandButton1_Click()
    Set sht = ActiveSheet
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    With Sheets("Sheet2")
      For rw = 3 To lr Step 2
        .Range("S3") = sht.Cells(rw, "B")
        .Range("K5") = sht.Cells(rw, "D").Value & vbLf & sht.Cells(rw, "E").Value & ", " & sht.Cells(rw, "F").Value
        .Range("S32") = sht.Cells(rw + 1, "B")
        .Range("K34") = sht.Cells(rw + 1, "D").Value & vbLf & sht.Cells(rw + 1, "E").Value & ", " & sht.Cells(rw + 1, "F").Value
        .PrintPreview
      Next rw
    End With
    End Sub
    Attached Files Attached Files

  7. #7
    @p45cal
    Thank you very much!
    Tha's exactly what I needed! ..but, I need also to insert one blank "paper", so that I could write on the back of the this form dat from column G.
    And is there any way to vba do automatic creation multi forms ? so if I have 100 entries in the Sheet3 - 2 forms per page, I need 50 forms?
    I don't know am I clear?

    Thanks again, and I no need to cross-posting because you are great

  8. #8
    Ok, I was working "all step by step" I inserted 10 forms in sheet called "Povratnica". In sheet0 "Tabela" I have button "INSERT!" and basically what I did is recording a macro for 10 rows. You can see that each even page is back of of the form (here I need the column F).

    Only I have a trouble that macro doesn insert in the first form for date..I dont know why...
    dropbox.com/s/l21xyjr4io0i01s/Test.xlsm

  9. #9
    This code that you wrote it is great! But I need only one if statement for column C, to fill in only values that contains "postexpress".
    I tried to edit the code but eroor comes up

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •