Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Border & Sum

Hi, I have lines of data which vary dynamically, i.e. could be 5,7,11 lines
etc.

At the bottom of the last line, I always need a border and a Sum Amount,
help is greatly appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Border & Sum

Hi,
This puts a border above and below the cell you are on.
Sub Macro1()
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub


"teresa" wrote:

Hi, I have lines of data which vary dynamically, i.e. could be 5,7,11 lines
etc.

At the bottom of the last line, I always need a border and a Sum Amount,
help is greatly appreciated

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Border & Sum

This should do the trick:

Option Explicit
Sub get_total()
Dim intNumRows As Integer, c As Variant, lngCellTotal As Long
intNumRows = Cells(50, "A").End(xlUp).Row
With Range("A" & intNumRows + 1)
.Borders(xlEdgeLeft).Weight = xlMedium
.Borders(xlEdgeTop).Weight = xlMedium
.Borders(xlEdgeBottom).Weight = xlMedium
.Borders(xlEdgeRight).Weight = xlMedium
End With
For Each c In Range("A1", "A" & intNumRows)
lngCellTotal = lngCellTotal + c.Value
Next
Range("A" & intNumRows + 1) = lngCellTotal

End Sub



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Border & Sum

Here is a slightly different interpretation. Change A to reflect the column
containing the data:

Sub get_total()
Dim rng As Range
Dim intNumRows As Integer, c As Variant, _
lngCellTotal As Long
intNumRows = Cells(50, "A").End(xlUp).Row
With Range("A" & intNumRows + 1)
.Borders(xlEdgeTop).Weight = xlMedium
Set rng = Range("A1", "A" & intNumRows)
.Formula = "=Sum(" & rng.Address & ")"
End With
End Sub

--
Regards,
Tom Ogilvy

"Claud Balls" wrote in message
...
This should do the trick:

Option Explicit
Sub get_total()
Dim intNumRows As Integer, c As Variant, lngCellTotal As Long
intNumRows = Cells(50, "A").End(xlUp).Row
With Range("A" & intNumRows + 1)
.Borders(xlEdgeLeft).Weight = xlMedium
.Borders(xlEdgeTop).Weight = xlMedium
.Borders(xlEdgeBottom).Weight = xlMedium
.Borders(xlEdgeRight).Weight = xlMedium
End With
For Each c In Range("A1", "A" & intNumRows)
lngCellTotal = lngCellTotal + c.Value
Next
Range("A" & intNumRows + 1) = lngCellTotal

End Sub



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Border PL Excel Discussion (Misc queries) 3 July 10th 09 05:20 AM
border on last cell of page effects border on beginning cell of ne GaryE Excel Discussion (Misc queries) 0 March 23rd 09 05:47 AM
Border Neil Pearce Excel Discussion (Misc queries) 0 April 10th 08 02:28 PM
Changing the border of one cell s/n change the border of adjacent gjanssenmn Excel Discussion (Misc queries) 2 October 5th 05 08:35 PM
outside border Jenna New Users to Excel 1 February 15th 05 05:23 AM


All times are GMT +1. The time now is 06:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"