ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Format Fill Down to Last Row (https://www.excelbanter.com/excel-worksheet-functions/165717-format-fill-down-last-row.html)

Keep It Simple Stupid

Format Fill Down to Last Row
 
I know it is possible for formulas, etc, but is it possible to have a macro
that formats a column of cells and only formats down to the last row? It
will always be the same column, but there will be a different number of rows
each time.

FSt1

Format Fill Down to Last Row
 
hi,
yes it is possible.
What row?
what format?

regards
FSt1

"Keep It Simple Stupid" wrote:

I know it is possible for formulas, etc, but is it possible to have a macro
that formats a column of cells and only formats down to the last row? It
will always be the same column, but there will be a different number of rows
each time.


FSt1

Format Fill Down to Last Row
 
hi
excuse....what column?

regards
FSt1

"FSt1" wrote:

hi,
yes it is possible.
What row?
what format?

regards
FSt1

"Keep It Simple Stupid" wrote:

I know it is possible for formulas, etc, but is it possible to have a macro
that formats a column of cells and only formats down to the last row? It
will always be the same column, but there will be a different number of rows
each time.


Keep It Simple Stupid

Format Fill Down to Last Row
 
Format: The diagonal line going through the cell (lower left to upper right)
Row: The last row that is populated (remember, this will change everytime I
run the macro)
Column: D

In other words:
Selection.Borders(xlDiagonalDown).Linestyle=xlNone
With selection.borders(xlDiagonalup)
.Linestyle=xlContinuous
.Weight=xlHairline
..ColorIndex=xlAutomatic
....

"FSt1" wrote:

hi,
yes it is possible.
What row?
what format?

regards
FSt1

"Keep It Simple Stupid" wrote:

I know it is possible for formulas, etc, but is it possible to have a macro
that formats a column of cells and only formats down to the last row? It
will always be the same column, but there will be a different number of rows
each time.


FSt1

Format Fill Down to Last Row
 
hi
this should work. try it and post back if problems.
sub addformats()
Dim r As Long
lr = cells(Rows.Count, "D").End(xlUp).Row
Range("D1:D" & lr).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
With Selection.Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub

Regards
FSt1

"Keep It Simple Stupid" wrote:

Format: The diagonal line going through the cell (lower left to upper right)
Row: The last row that is populated (remember, this will change everytime I
run the macro)
Column: D

In other words:
Selection.Borders(xlDiagonalDown).Linestyle=xlNone
With selection.borders(xlDiagonalup)
.Linestyle=xlContinuous
.Weight=xlHairline
.ColorIndex=xlAutomatic
...

"FSt1" wrote:

hi,
yes it is possible.
What row?
what format?

regards
FSt1

"Keep It Simple Stupid" wrote:

I know it is possible for formulas, etc, but is it possible to have a macro
that formats a column of cells and only formats down to the last row? It
will always be the same column, but there will be a different number of rows
each time.


Gord Dibben

Format Fill Down to Last Row
 
Sub Auto_Format()
Dim Lrow As Long
With ActiveSheet
Columns(3).Cells.Interior.ColorIndex = xlNone
Lrow = Range("C" & Rows.Count).End(xlUp).Row
Range("C1:C" & Lrow).Interior.ColorIndex = 3
End With
End Sub


Gord Dibben MS Excel MVP

On Mon, 12 Nov 2007 07:18:02 -0800, Keep It Simple Stupid
wrote:

I know it is possible for formulas, etc, but is it possible to have a macro
that formats a column of cells and only formats down to the last row? It
will always be the same column, but there will be a different number of rows
each time.



Gord Dibben

Format Fill Down to Last Row
 
I would add one line to clear the borders from the previous range.

Otherwise they will remain if number of rows is less than previous.

Sub addformats()
Dim r As Long
lr = Cells(Rows.Count, "D").End(xlUp).Row
Columns("D").Borders(xlDiagonalUp).LineStyle = xlNone 'add this line
Range("D1:D" & lr).Select
'this line not needed Selection.Borders(xlDiagonalDown).LineStyle = xlNone
With Selection.Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub


Gord

On Mon, 12 Nov 2007 08:20:05 -0800, FSt1 wrote:

hi
this should work. try it and post back if problems.
sub addformats()
Dim r As Long
lr = cells(Rows.Count, "D").End(xlUp).Row
Range("D1:D" & lr).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
With Selection.Borders(xlDiagonalUp)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub

Regards
FSt1

"Keep It Simple Stupid" wrote:

Format: The diagonal line going through the cell (lower left to upper right)
Row: The last row that is populated (remember, this will change everytime I
run the macro)
Column: D

In other words:
Selection.Borders(xlDiagonalDown).Linestyle=xlNone
With selection.borders(xlDiagonalup)
.Linestyle=xlContinuous
.Weight=xlHairline
.ColorIndex=xlAutomatic
...

"FSt1" wrote:

hi,
yes it is possible.
What row?
what format?

regards
FSt1

"Keep It Simple Stupid" wrote:

I know it is possible for formulas, etc, but is it possible to have a macro
that formats a column of cells and only formats down to the last row? It
will always be the same column, but there will be a different number of rows
each time.




All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com