+ Reply to Thread
Results 1 to 11 of 11

Need macro to draw border

  1. #1
    Registered User
    Join Date
    07-25-2017
    Location
    India
    MS-Off Ver
    2007
    Posts
    5

    Need macro to draw border

    Hi Helpers,
    I have a table with some data. File "format preserve.xls" is uploaded with thread.
    In my sheet, boxes have been created of two cells each with border only around group of two cells.

    I need to drag and drop a box from one location to another location within table.

    Now when I drag and drop for example I11 and I12 cell to L9 and L10 then right border around I11 and I12 box is removed.

    I know that there is no solution to preserve border while drag and drop.

    Many times drag and drop is required to be done.

    So, is it possible to write a macro that will select outline border from font menu and apply it on old location (e.g. I11 and I12) as well as on new location (e.g. L9 and L10).

    Whenever such drag and drop is used, it must apply outline border on old box and new box.

    Note: Drag and drop is most convenient and faster way to shift data for me and other users using this sheet.

    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need macro to draw border

    Right Click on the sheet name at the bottom of excel and select view code

    Paste this code into the module that opens and close it.

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need macro to draw border

    This event isn't quite right but if you select the range that you dragged after your drop it will reinstate the border:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    07-25-2017
    Location
    India
    MS-Off Ver
    2007
    Posts
    5

    Re: Need macro to draw border

    Dear Helper,

    Thanks a ton for helping me. My problem is almost solved but 4 things which needs to be corrected.

    1. When I drag and drop pair of two cells, after dropping data cell A3 and A4 shows the blinking effect as it is observed while selecting cells for copy purpose using ctrl+c key. Can this effect be removed?

    2. When I drag and drop pair of two cells, after dropping data , cell range a14 to q19 get highlighted like when we select multiple rows. Can this effect be removed?

    3. Font size, alignment gets changed of whole table. Actually my original table contains lot of formatting based on some formulas and conditional formatting. It must be preserved. Nothing should be changed except redrawing border. Can we preserve every kind of formatting and have only border redrawing?

    4. While dragging and dropping few cells it shows a dialogue box with message "Do you want to replace the content of destination cells? ". This is annoying. Can this effect be removed?

    Thanks in advance.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need macro to draw border

    I can't squelch the alert

    But. it's not my event that you're using
    Last edited by xladept; 07-27-2017 at 02:46 PM.

  6. #6
    Registered User
    Join Date
    07-25-2017
    Location
    India
    MS-Off Ver
    2007
    Posts
    5

    Re: Need macro to draw border

    Dear Helper,

    Thanks a ton for helping me. My problem is almost solved but 4 things which needs to be corrected.

    1. When I drag and drop pair of two cells, after dropping data cell A3 and A4 shows the blinking effect as it is observed while selecting cells for copy purpose using ctrl+c key. Can this effect be removed?

    2. When I drag and drop pair of two cells, after dropping data , cell range a14 to q19 get highlighted like when we select multiple rows. Can this effect be removed?

    3. Font size, alignment gets changed of whole table. Actually my original table contains lot of formatting based on some formulas and conditional formatting. It must be preserved. Nothing should be changed except redrawing border. Can we preserve every kind of formatting and have only border redrawing?

    4. While dragging and dropping few cells it shows a dialogue box with message "Do you want to replace the content of destination cells? ". This is annoying. Can this effect be removed?

    Thanks in advance.

  7. #7
    Registered User
    Join Date
    07-25-2017
    Location
    India
    MS-Off Ver
    2007
    Posts
    5

    Re: Need macro to draw border

    Extremely sorry sir / madam. I am new to this forum so I made a mistake. Sorry once again.
    Sir I tried your code as well. But while dragging and dropping, some border disappears.
    I want to redraw border without affecting other conditional formatting and font style, size , alignment etc.
    everything should remain as it is.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need macro to draw border

    Well, I told you that you could reestablish the border by just re-selecting the range that you dragged from - I thought it would be easier than running a program to reinstate those borders -

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need macro to draw border

    1. add this line to the end of the macro

    Please Login or Register  to view this content.
    2. I do not see that effect.

    3. Do not use paste special format.

    Instead format each pair of cells seperately.

    Please Login or Register  to view this content.

    4. I could not find a solution.
    Last edited by mehmetcik; 07-28-2017 at 09:09 PM.

  10. #10
    Registered User
    Join Date
    07-25-2017
    Location
    India
    MS-Off Ver
    2007
    Posts
    5

    Re: Need macro to draw border

    Thanks sir for helping me but unfortunately solution is not working.
    Border at some places still disappear.

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need macro to draw border

    Refer to post #8:|

+ 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. Toggling off "Draw Border"
    By PacFan01 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-15-2015, 09:30 PM
  2. Draw a border based on current month
    By JT_2111 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2014, 06:44 PM
  3. Pivot table draw border based on order number
    By Risto85 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2014, 08:56 AM
  4. Draw bottom border on every rows from top to bottom
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2013, 09:52 AM
  5. How to write a Series (Sr.No) & Draw Border for Spaced Data using VBA?
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2011, 07:52 AM
  6. Using a macro to draw the cell border
    By Jeroen1000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-30-2009, 10:06 AM
  7. [SOLVED] Erase & Draw Border functions no longer work
    By bob m in forum Excel General
    Replies: 2
    Last Post: 02-25-2005, 02:06 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