sjohnson77
New Member
- Joined
- Apr 17, 2021
- Messages
- 11
- Office Version
- 365
- 2019
- Platform
- Windows
Hi Everyone
I am experiencing an issue with a macro I created to help format some raw data sheets I have to deal with at work. The macro I have made is almost perfect, except I need the macro to detect the data range of the cells in use (as this changes with each RAW data file I receive) and put a thick line border around the outside of the data (not each cell individually). The column length always stays the same it is just the number of rows that changes depending on how much data I get.
Could anyone help to amend the below for me so that the border issue can be resolved?
Any help would be greatly appreciated!
Thanks
Saul
I am experiencing an issue with a macro I created to help format some raw data sheets I have to deal with at work. The macro I have made is almost perfect, except I need the macro to detect the data range of the cells in use (as this changes with each RAW data file I receive) and put a thick line border around the outside of the data (not each cell individually). The column length always stays the same it is just the number of rows that changes depending on how much data I get.
Could anyone help to amend the below for me so that the border issue can be resolved?
VBA Code:
Columns("A:D").Select
Range("D1").Activate
Selection.EntireColumn.Hidden = False
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
Rows("2:5").Select
Selection.Delete Shift:=xlUp
Range("B1").Select
Selection.ClearContents
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("C:E").Select
Selection.Delete Shift:=xlToLeft
Columns("F:R").Select
Selection.Delete Shift:=xlToLeft
Columns("G:I").Select
Selection.Delete Shift:=xlToLeft
Columns("M:M").Select
Selection.Delete Shift:=xlToLeft
Columns("P:P").Select
Selection.Delete Shift:=xlToLeft
Columns("P:P").EntireColumn.AutoFit
Columns("Q:T").Select
Selection.Delete Shift:=xlToLeft
Columns("T:AD").Select
Selection.Delete Shift:=xlToLeft
Range("B3:S76").Select
Range("S3").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Columns("L:L").Select
Selection.ColumnWidth = 14.14
Columns("J:J").Select
Selection.ColumnWidth = 13
ActiveWindow.SmallScroll Down:=51
Range("C78").Select
Rows("77:77").RowHeight = 12.75
Rows("77:92").Select
Selection.Delete Shift:=xlUp
Rows("4:79").Select
Range("A79").Activate
Selection.RowHeight = 12.75
ActiveWindow.SmallScroll Down:=-102
Range("B1:S1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.merge
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.Font.Size = 11
Selection.Font.Size = 12
Selection.Font.Bold = True
Selection.Font.Underline = xlUnderlineStyleSingle
End Sub
Any help would be greatly appreciated!
Thanks
Saul
Last edited by a moderator: