+ Reply to Thread
Results 1 to 18 of 18

Draw automatic borders using VBA

  1. #1
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Post Draw automatic borders using VBA

    I have a file , in which every week i will update data. First,i will enter week number, next i will fill up some data on two columns (material no and part id). After that I press update button
    i need to see "Outside borders" automatically drawn.
    pls help me , how to do that?
    Attached Files Attached Files
    Last edited by joh46k; 06-27-2013 at 04:29 AM.

  2. #2
    Registered User
    Join Date
    06-20-2013
    Location
    Hā Nội
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Draw automatic borders using VBA

    Quote Originally Posted by joh46k View Post
    I have a file , in which every week i will update data. First,i will enter week number, next i will fill up some data on two columns (material no and part id). After that I press update button
    i need to see "Outside borders" automatically drawn.
    pls help me , how to do that?
    I don't understand your request ! but I try to write a code --> You can test this code ?

    Run sub NHM ()
    Please Login or Register  to view this content.
    Last edited by HungDHXD; 06-24-2013 at 11:24 PM.

  3. #3
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Draw automatic borders using VBA

    Post this in you worksheet module code and when you make a change to the sheet it will automatically update for you.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  4. #4
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Post Re: Draw automatic borders using VBA

    @japandav : i have some questions
    1)In future ,if i want to increase the rows where do i need to make changes in the above code.
    2) Why the template file working as i wanted but i copy the same code paste in to my original file is not working as i wanted.
    Below i attached my excel original file sheet , pls check

    Thank you
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by joh46k; 06-25-2013 at 05:30 AM.

  5. #5
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Draw automatic borders using VBA

    Where are the week numbers? The Original file is different to the sample, so the code obviously won't work. How do tell each week?

  6. #6
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Draw automatic borders using VBA

    JapanDave: here I re-uploaded my file . My 1ST week start from ROW 4691.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Draw automatic borders using VBA

    Bump no response
    Last edited by joh46k; 06-28-2013 at 02:46 AM.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Draw automatic borders using VBA

    Hi, joh46k,

    taking JapanDaveīs concept of worksheet change please try this code and see if you may work with it (it will have an effect in the row you change/enter data). Code goes behind the sheet wwhich you want to monitor:
    Please Login or Register  to view this content.
    For updating with a Button I would check the date in Column M to build a range for applying borders there.

    HTH,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  9. #9
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Draw automatic borders using VBA

    @hahobe: thank you for your reply man ! i tried ur code but it is not what i wanted .

    if you see post #3 , japandave code: His template exactly achieve what i wanted but the problem is ,when i put that code inside my original ALL file(#6) it is not working as in the template that he attached in post #3.
    Can you help me , on that ?
    Last edited by joh46k; 06-27-2013 at 05:56 AM.

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Draw automatic borders using VBA

    Hi, joh46k,

    a slight update of the code:
    Please Login or Register  to view this content.
    As the file I was working on shows more than 600 KB I hope Iīve been working on your most current upload.

    Ciao,
    Holger
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Draw automatic borders using VBA

    @Hahobe : Bro did you tried Dave's post #3 attachment file ? i want something like that.

    I tried your file, it creating a border , only if I manually type the data from B to M column . If i tried to copy & paste some data on B to M column , it is not creating a border.

    If you tried DAVE'S post#3 file ,you will notice that you can type and also you can copy and pate as value , it will Automatically create a nice border for you .
    Last edited by joh46k; 06-27-2013 at 10:15 PM.

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Draw automatic borders using VBA

    Hi, joh46k,

    Quote Originally Posted by Post#11
    If i tried to copy & paste some data on B to M column , it is not creating a border.
    Quote Originally Posted by OP
    First,i will enter week number
    Code will work due to OP (besides that I donīt like areas in a table being left empty). I restricted the code to work for only one cell as entry with
    Please Login or Register  to view this content.
    Deactivating that line will definitely create a RTE when pasting.

    What are you pasting (area in the sample)? Is it always equal to a week or not? When will you enter the week number?

    i want something like that.
    What about answering the questions I just asked for finding out how to rewrite the event?

    Ciao,
    Holger

  13. #13
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Draw automatic borders using VBA

    OK, try this.

    I fixed some other little problems that were nagging me as well. This will update the boarders as you enter data in the table as you update the week No. and the Quarters Column in the B column. If you want it to update from other columns let me know.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JapanDave; 06-28-2013 at 05:27 AM.

  14. #14
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Draw automatic borders using VBA

    DAVE : Thanks so much bro ! for you help man it is working correctly and i find where is the problem ?

    i have cells that built with formulas that's the reason when every time, i enter the data the border keep expanding until 12000 rows and more than that.
    i just now tried to delete that formulas and tried again it works perfectly.

    Do you have any suggestion/ideas on how to solve that problem?

    Picture is attached below , pls check thank you
    Attached Images Attached Images
    Last edited by joh46k; 06-28-2013 at 06:22 AM.

  15. #15
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Draw automatic borders using VBA

    Repace the code with this,

    You really should have posted an exact copy of the workbook in the first place. I am on my 8th beer right now and it is getting hard to think straight! LOL

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JapanDave; 06-28-2013 at 06:46 AM.

  16. #16
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Draw automatic borders using VBA

    Thank you so much Japan dave and HaHoBe ! Great .It is working .

    Btw . The code works but i don't know how it's works #15 and #13 . It will be best, if you all write instruction or guide beside the code on how each line works .if not, you can choose important line . by using these symbol ' ' or # #

    Once again , Thanks very much .
    Last edited by joh46k; 06-30-2013 at 10:33 PM.

  17. #17
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Draw automatic borders using VBA

    No worries.

  18. #18
    Forum Contributor
    Join Date
    03-28-2013
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Draw automatic borders using VBA

    JapanDave : your code works WELL ,only after i delete the blank cells with formula . so How To delete blank cells in that "ALL" sheet coloumns?

    I have blank cells in Coloumn B and F to K
    Last edited by joh46k; 07-05-2013 at 03:35 AM.

+ 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