Select Section between blank rows

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,238
Office Version
2007
Platform
Windows
It would be more effective if you help us with an image of what you have before the formats and another image with what you expect of result.
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,933
Office Version
365
Platform
Windows
In that case how about
Code:
Sub srschicago()
   Dim Rng As Range
   For Each Rng In Range("A:A").SpecialCells(xlConstants).Areas
      Rng.Offset(1, 1).Resize(Rng.Count - 1).Interior.Color = 12566463
      Rng.Offset(1).Resize(Rng.Count - 1, 5).Borders.Weight = xlMedium
   Next Rng
End Sub
 

srschicago

Board Regular
Joined
Apr 14, 2017
Messages
59
Disregard the Col C Date issue after the section. I change the macro to delete the date cell earlier in the process.
 

srschicago

Board Regular
Joined
Apr 14, 2017
Messages
59
In that case how about
Code:
Sub srschicago()
   Dim Rng As Range
   For Each Rng In Range("A:A").SpecialCells(xlConstants).Areas
      Rng.Offset(1, 1).Resize(Rng.Count - 1).Interior.Color = 12566463
      Rng.Offset(1).Resize(Rng.Count - 1, 5).Borders.Weight = xlMedium
   Next Rng
End Sub
Thanks Fluff, but your code formats all of the sections with data in Col A and I do not want this. Only the section attached to the title cell I have selected. I would also like to sort the data by Col A so getting the range selected seems necessary.
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,817
Office Version
2010
Platform
Windows
Thanks Fluff, but your code formats all of the sections with data in Col A and I do not want this. Only the section attached to the title cell I have selected. I would also like to sort the data by Col A so getting the range selected seems necessary.
Please read Message #11 ... complying with it will remove the necessity to keep guessing at what your data looks like and what you are ultimately trying to do with it (as they say, a picture is worth a thousand words).
 

srschicago

Board Regular
Joined
Apr 14, 2017
Messages
59
I installed the MrExcel HTML Maker and added the add-in to Excel. The buttons to select options were activating, but the button to create the HTML image would not. I gave up on it because of time.
Speaking of your time, thank you all for yours. I solved my problem using CurrentRegion after all.
Basically I have a series of tables vertically aligned and separated by blank rows. Each table has a Title cell above it.
Here is the code I used to format the 2nd table. The Title cell is where I start in for the macro.
Code:
<>
Sub rangeselect()
    ActiveCell.Select
    Selection.CurrentRegion.Offset(1).Resize(Selection.CurrentRegion.Rows.Count - 1).Select
'Format borders....
    Selection.CurrentRegion.Offset(1, 1).Resize(Selection.CurrentRegion.Rows.Count - 1, _
    Selection.CurrentRegion.Columns.Count - 4).Select
'Fill Column B with gray...
    
End Sub
[END]<>
Sorry that I don't remember the correct code posing syntax.
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,933
Office Version
365
Platform
Windows
Glad you sorted it & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,096,068
Messages
5,448,196
Members
405,492
Latest member
DPuser

This Week's Hot Topics

Top