Closed Thread
Results 1 to 18 of 18

Change cell border & outline in a macro

  1. #1
    Registered User
    Join Date
    03-25-2008
    Posts
    66

    Change cell border & outline in a macro

    Guys,

    I have an excel sheet that is pulling data from other sheet based on some cretaria...i want a macro that when ran on this excel fixes column width , makes cell border as "dotted" and outline the area with Thick Outline.

    I am attaching a sample sheet with raw worskeet (unformatted) and one formatted which i did manually.

    Columns in worksheet will remain same but rows can change....can any1 provide me with a macro for this plz...

    this is what i need ,

    Column A width to be 31.00
    Column B,C,D to be 11.29
    Column E to be 7.00

    Cell Border to be dotted,and thick box border around rows in Column B,C,D,E where columns rows has data.
    Attached Files Attached Files

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Get the basic code bu recording a macro. the generated code can then be edited.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-25-2008
    Posts
    66
    Quote Originally Posted by royUK
    Get the basic code bu recording a macro. the generated code can then be edited.
    thats the code...and dont worry abt column width...i fixed that...



    Please Login or Register  to view this content.
    Last edited by royUK; 06-01-2008 at 04:55 AM.

  4. #4
    Registered User
    Join Date
    03-25-2008
    Posts
    66
    now what i want is that macro shud search numeric values in B,C,D,E and than format there cells , once cells are formatted rows in colum B,C,D,E with numeric values shud get this THICK BOX BORDER as shown in above macro or screenshot attached before ...my sheet is divided into 2 parts "INTERNALS" and "EXTERNALS" . and i have mentioned this columnA , so a cell in "A" displays "INTERNAL" (i.e. A2 fixed ) where INTERNAL sites end , a cell in rowA displays "EXTERNALS" )not fixed as it depends on INTERNAL sites rows which can change) and all external data falls under that. I need seprated THICK BORDER FOR BOTHs...plz HELP....

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    please edit your post with Code Tags.

    You can start by removing all the lines like

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481
    I read your code, and tried to run it, and it turned out nothing like your formatted example, so I recorded a macro, cleaned it up a bit, and it looks something like this...
    Please Login or Register  to view this content.
    It looks like, your example, let me know if there is anything missing...

  7. #7
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Namz, please comply with the moderators request (RoyUk) when you have done so i will gladly undelete davesexcel's solution for you!

    As per our rules, we feel we cannot answer a question until they are adhered to as this makes our job easier and helps you get the responses you need, everyone gets asked to do the same to keep our forum a great place to visit!

    If you are experiencing trouble or need help then please PM myself or a moderator for help.
    Not all forums are the same - seek and you shall find

  8. #8
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717
    Hi,

    If you are looking to just format the borders with outer thick lines and inner dotted line then this code will be sufficient.


    After typing this code in VBA editor, return to excel.
    Click on tools menu , then macors.
    It will Open the macros window, here you click on option button.
    In will open a small window called MACROS OPTION.
    Here you can put shortkey to run marcos like
    Ctrl + t ( so when u press control key and t macros will run).


    To run macros select the range where u want the formatting and then click control key + T
    Please Login or Register  to view this content.
    If you need further assistance or modification in the macros you can PM me.

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Quote Originally Posted by Shijesh Kumar
    Hi,

    If you are looking to just format the borders with outer thick lines and inner dotted line then this code will be sufficient.


    After typing this code in VBA editor, return to excel.
    Click on tools menu , then macors.
    It will Open the macros window, here you click on option button.
    In will open a small window called MACROS OPTION.
    Here you can put shortkey to run marcos like
    Ctrl + t ( so when u press control key and t macros will run).


    To run macros select the range where u want the formatting and then click control key + T
    Please Login or Register  to view this content.
    If you need further assistance or modification in the macros you can PM me.

    Slightly shorter

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  10. #10
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717
    Hey,

    U r right... i was trying the same but i didnt know BorderAround feather...

    Thanks buddy the increasing my excel VBA knowledge

    namz use this because its better one
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    03-25-2008
    Posts
    66
    Quote Originally Posted by Simon Lloyd
    Namz, please comply with the moderators request (RoyUk) when you have done so i will gladly undelete davesexcel's solution for you!

    As per our rules, we feel we cannot answer a question until they are adhered to as this makes our job easier and helps you get the responses you need, everyone gets asked to do the same to keep our forum a great place to visit!

    If you are experiencing trouble or need help then please PM myself or a moderator for help.
    Hi Simon , just pasted my edited code...let me know what other changes can i do that wud make easier for experts on this forum to assist me..cheerz!!

  12. #12
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Namz you need to add code tags to your code please re post your code using code tags (highlight your code and press # when in the new post window) i will then un-delete the relevant posts!

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Post locked due to namz ignoring the rules & not responding to moderator's requests.

  14. #14
    Registered User
    Join Date
    03-25-2008
    Posts
    66

    Unhappy Macro for cell border style & outline

    Hi Admin & Moderator, is this what i was supposed to do ?
    Plz advise i am newbie to macros and to this forum so dont understand lot of things...


    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    03-25-2008
    Posts
    66
    This is what a macro code should do ; Hope this makes sense...thanks.

    1. Finds numeric values in rows falling in colum B,C,D,E , than border those cells as dotted (i.e. right click on cell - format column - Border - Style - 3rs on top left row).

    2. After filling cell border style as mentioned above , macro should do a THICK BOX BORDER around a cells falling above dotted cells.. i.e. one big sqaure outlined contaiing dotted cells with numeric values.

    3. Trick part , my sheet is divided into 2 parts , INTERNAL and EXTERNAL. So i have writen "INTERNAL" in A1 cell and EXTERNAL in 'A' row in last row after INTERNAL lines. So the THICK BOX BORDER as requested in pt 2 shud be separted ones for INTERNAL and sep from EXTERNAL.

  16. #16
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    The code tags are what we requested. thanks for doing that.

    I have edited the original post, restored the hidden answers & merged the threads.
    Last edited by royUK; 06-01-2008 at 04:58 AM.

  17. #17
    Registered User
    Join Date
    03-25-2008
    Posts
    66
    Quote Originally Posted by royUK
    The code tags are what we requested. thanks for doing that.

    I have edited the original post, restored the hidden answers & merged the threads.

    Hi roy, can i plz have some help my last reply on post " Copy\Paste multiple criteria based rows to new sheet "

  18. #18
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Namz, you haven't complied with my request for a post in the "General" forum agreeing to our rules which are in place to help everyone even you!

    Please comply or i will have no option but to ban you, i really don't want to take this course of action as we try to keep these forums a happy friendly community.

Closed 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