Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Border | Excel Discussion (Misc queries) | |||
border on last cell of page effects border on beginning cell of ne | Excel Discussion (Misc queries) | |||
Border | Excel Discussion (Misc queries) | |||
Changing the border of one cell s/n change the border of adjacent | Excel Discussion (Misc queries) | |||
outside border | New Users to Excel |