Joe
Rather than have one long macro I broke it up into 3 macros and
declarations. Paste all of this into a standard module. Watch out for line
wrapping.
I assumed that you want the header row in only row 1 and not repeated
every time you run the macro, so I wrote the macros that way. If this is
not right, let me know and I'll massage it as needed for you. When you want
to run this, run only macro NEWSHT2. The other two macros run
automatically.
If you have errors it will be because of line wrapping in this message.
If you wish, send me an email with a valid email address for you and I'll
send you the small file I used for this with the code included. My email
address is
[email protected]. Remove the "nop" from this address. HTH
Otto
Option Explicit
Dim RngG As Range
Dim i As Range
Dim FirstCell As Range
Dim LastCell As Range
Dim TheRng As Range
Sub NEWSHT2()
Set RngG = Range("G1:G65536")
If [G1].Value <> "Remarks" Then
Set FirstCell = Range("G1")
Call IntitialSetup
Else
For Each i In RngG
If i.Borders(xlEdgeLeft).LineStyle = xlNone Then Exit For
Next i
Set FirstCell = i
End If
Set LastCell = Range(FirstCell, FirstCell.Offset(20, 6))
Set TheRng = Range(FirstCell, LastCell)
Call PutBorders
End Sub
Sub IntitialSetup()
Rows("1:1").RowHeight = 20
Range("G1").Value = "Remarks"
Range("H1").Value = "Proposed" & Chr(10) & "Elevation"
Range("I1").Value = "Exisiting" & Chr(10) & "Elevation"
With Range("H1:I1").Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
End With
Range("J1").Value = "Diff."
Range("K1").Value = "Fill"
Range("L1").Value = "Cut"
Range("M1").Value = "Description"
Rows("1:1").EntireRow.AutoFit
Range("M:M,G:G").ColumnWidth = 20
Columns("H:I").ColumnWidth = 12
With Range("G1").Resize(, 7)
.BorderAround LineStyle:=xlContinuous, Weight:=xlThick
End With
End Sub
Sub PutBorders()
With TheRng
.Borders.LineStyle = xlContinuous
.Borders.Weight = xlThin
.BorderAround LineStyle:=xlContinuous, Weight:=xlThick
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
Range("G1").Select
End Sub