KlayontKress
Board Regular
- Joined
- Jan 20, 2016
- Messages
- 67
- Office Version
- 2016
- Platform
- Windows
To all,
I'm looking for a macro to auto select a region from a fixed point, E6, down to the last row in the column with data (the column has non continuous data), and as far right as there are columns that have data and add thin borders. This is a secondary request for a previous post I received help on. The data format will be similar to the table at the bottom of this post but there many be hundreds of rows.
I tried to record a macro to do this and it gave me the large section of code at the bottom of the post to select this region. The problem I have, is the range is running from cell E1 to the last row with data in it all the way to the last column possible in the worksheet. I thought that the code
would change the selection from the top of the worksheet to the first row with data in it but this doesn't seem to be working.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[TD]H
[/TD]
[TD]I
[/TD]
[TD]J
[/TD]
[TD]K
[/TD]
[TD]L
[/TD]
[TD]M
[/TD]
[TD]N
[/TD]
[TD]O
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]BLAH
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]BLAH
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]BLAH
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4
[/TD]
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
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10
[/TD]
[TD]ASDF
[/TD]
[TD]#
[/TD]
[TD]FDSA
[/TD]
[TD][/TD]
[TD]$$
[/TD]
[TD]$$
[/TD]
[TD]$
[/TD]
[TD]$$$
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]11
[/TD]
[TD]ASDF
[/TD]
[TD]#
[/TD]
[TD][/TD]
[TD][/TD]
[TD]$$
[/TD]
[TD]$
[/TD]
[TD]$$$
[/TD]
[TD]$
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12
[/TD]
[TD]ASDF
[/TD]
[TD]#
[/TD]
[TD]ASDF
[/TD]
[TD][/TD]
[TD]$
[/TD]
[TD]$$$
[/TD]
[TD]$$
[/TD]
[TD]$$
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]14
[/TD]
[TD](WANT TO INSERT TOTAL HERE)
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD](WANT TO TOTAL COLUMN FROM E7:E12)
[/TD]
[TD](WANT TO TOTAL COLUMN FROM F7:F12)
[/TD]
[TD](WANT TO TOTAL COLUMN FROM G7:G12)
[/TD]
[TD](WANT TO TOTAL COLUMN FROM H7:H12)
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Thanks in advance,
I'm looking for a macro to auto select a region from a fixed point, E6, down to the last row in the column with data (the column has non continuous data), and as far right as there are columns that have data and add thin borders. This is a secondary request for a previous post I received help on. The data format will be similar to the table at the bottom of this post but there many be hundreds of rows.
I tried to record a macro to do this and it gave me the large section of code at the bottom of the post to select this region. The problem I have, is the range is running from cell E1 to the last row with data in it all the way to the last column possible in the worksheet. I thought that the code
Code:
Range(Selection, Selection.End(xlDown)).Select
Code:
Range("E1").Select
'following code is to find the bottom of the page
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
'code looks up to find the last row
Selection.End(xlUp).Select
'code selectes from the last cell to the top of the sheet
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select
'code selects from the top of the sheet to the first row with data in it
Range(Selection, Selection.End(xlDown)).Select
'at this point, I should have everything from the last row to the first row selected
'code selects all of the columns to the right with data
Range(Selection, Selection.End(xlToRight)).Select
'code below adds the borders
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[TD]H
[/TD]
[TD]I
[/TD]
[TD]J
[/TD]
[TD]K
[/TD]
[TD]L
[/TD]
[TD]M
[/TD]
[TD]N
[/TD]
[TD]O
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]BLAH
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]BLAH
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]BLAH
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]BLAH
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
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TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]11
[/TD]
[TD]ASDF
[/TD]
[TD]#
[/TD]
[TD][/TD]
[TD][/TD]
[TD]$$
[/TD]
[TD]$
[/TD]
[TD]$$$
[/TD]
[TD]$
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12
[/TD]
[TD]ASDF
[/TD]
[TD]#
[/TD]
[TD]ASDF
[/TD]
[TD][/TD]
[TD]$
[/TD]
[TD]$$$
[/TD]
[TD]$$
[/TD]
[TD]$$
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]14
[/TD]
[TD](WANT TO INSERT TOTAL HERE)
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD](WANT TO TOTAL COLUMN FROM E7:E12)
[/TD]
[TD](WANT TO TOTAL COLUMN FROM F7:F12)
[/TD]
[TD](WANT TO TOTAL COLUMN FROM G7:G12)
[/TD]
[TD](WANT TO TOTAL COLUMN FROM H7:H12)
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Thanks in advance,