+ Reply to Thread
Results 1 to 11 of 11

Format Cells between empty rows until there is no more data

  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 365 ProPlus
    Posts
    15

    Format Cells between empty rows until there is no more data

    I am working with a macro that sorts my data. I would like to add VBA code to format the boundary of data between the column range of A:H and between the empty rows. I have attached the example of the finished look I am trying to get and what I start with. Any help is greatly appreciated. Thanks!

    -E.D.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Format Cells between empty rows until there is no more data

    Hi and welcome to the forums,

    try this:
    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    06-20-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 365 ProPlus
    Posts
    15

    Re: Format Cells between empty rows until there is no more data

    I put your code at the end of what I am using and I get this error:
    Compile error:
    Duplicate declaration in current scope.

    The "i As Byte" in the "Dim i As Byte" line is highlighted.

    I have this code above what you have.
    Please Login or Register  to view this content.
    Last edited by edebraal; 06-21-2013 at 06:45 PM.

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Format Cells between empty rows until there is no more data

    Hi,

    The code is not intended to be pasted below other code, especially when you don't know whats happening there, use it as a separate sub by calling it at the end of your main procedure.

  5. #5
    Registered User
    Join Date
    06-20-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 365 ProPlus
    Posts
    15

    Re: Format Cells between empty rows until there is no more data

    Hi,

    Sorry about that. I am very new to this and am trying to update a macro I didn't create. I created it as you said to and I get and Error 9: Subscript out of range

    Thanks for all your help!

  6. #6
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Format Cells between empty rows until there is no more data

    Hi,

    I assume its in the following line caused by a missing worksheet called "Start"
    Please Login or Register  to view this content.
    Can the sheetname change or is it every time the same you run the code on?

  7. #7
    Registered User
    Join Date
    06-20-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 365 ProPlus
    Posts
    15

    Re: Format Cells between empty rows until there is no more data

    Hi,

    I changed the code to say Sheet1 which is the typical name I use. Thanks for all your help you solved it and will save me many hours down the road!

  8. #8
    Registered User
    Join Date
    06-20-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 365 ProPlus
    Posts
    15

    Re: Format Cells between empty rows until there is no more data

    Result.xlsx
    Start.xlsx

    Hi,

    I have been using the macro you helped me with and ran into a small problem. If there is no data in 2 consecutive cells side by side the formatting will not go out to row H it will stop. I have attached an example of what I started with and what happened. Is there a simple fix for this?

  9. #9
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Format Cells between empty rows until there is no more data

    Hi,
    try
    Please Login or Register  to view this content.
    What I did:
    Instead of using the "currentregion" of a cell I check the max number of columns in row 1 first to determine how many columns should be "bordered"

  10. #10
    Registered User
    Join Date
    06-20-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 365 ProPlus
    Posts
    15

    Re: Format Cells between empty rows until there is no more data

    Thanks! That worked!

  11. #11
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Format Cells between empty rows until there is no more data

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ 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