+ Reply to Thread
Results 1 to 6 of 6

Select and format to end of row

  1. #1
    Registered User
    Join Date
    03-14-2007
    Posts
    58

    Select and format to end of row

    I need help with a macro that will select data to the end of the row. Each sheet has the same basic formatting. A1 contains a name. B1, C1, D1 are column headers. B2:B is data. C2:C is data and always stops at the same row B2:B range does. The only differences between the sheets is that they might not stop at the same row. I want a macro that merges A1 vertically as shown in my spread sheet to the end of column B and C. I want a border around the merged data, as well as around the B data and the C data individually.

    I need a macro that selects B2 through the end of the items on B and selects it, then formats it accordingly. Then I need a macro or the same macro that selects C2 through the last row of the C column.

    Here's the same spreadsheet with a macro that merges A1. Now I just need it to go from b2 through the end of B and then from c2 through the end of c. I've played with it so much over the past few weeks as well as with help and suggestions from people that got me this far and I'm giving up on it now. Please help.. Thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Hopefully you have to use this code more than once!

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    In the code provided above, I have used the same border-setting block of code four times (Range A1:Ax, Range B1:D1, Range B2:Bx, Range D2). In an effort to shorten the code, is there a way to store this block of code separately and call it on those three occasions with one line of code each? Or some other way? It works as is, but it just seems longer than it has to be.

    The code section in question is:
    Please Login or Register  to view this content.
    Thanks!
    Last edited by Paul; 04-06-2007 at 05:10 PM.

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Try this

    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Thanks, Mud. I think we'd just have to leave out a few lines from the ApplyFormatting subroutine since they only apply to the merged cells in column A

    Just the Border properties needed to be coded in there, since the font sizes and column widths change from range to range. I also added ScreenUpdating = False & ScreenUpdating = True to make it cleaner.

    Thanks for your help!

    I guess this would be the final code then:

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Paul

    I new that about the font sizing & I have no idea why I left that part of the code in the ApplyFormatting macro

    The amendments you posted back should certainly give you what you want.

    Gald to have been able to assist you

+ 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