Macro help
Posted by Rob on August 02, 2001 1:50 PM
Hi everyone,
Ivan Moala gave me this code, I was wondering if he, or someone else could modify it to format ALL cells with data in them, not just the first row. Also, the code puts a formula in column C which adds the first 2 columns. What if I wanted it to put the formula in column D which added columns A, B, and C? I've tried playing with it, but like I told him, without much success. I appreciate the help :) Heres the code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
If Target.Columns.Count < 2 Then
If Target <> "" Then
With Target
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
'bold
.Font.Bold = True
'add formula to "C"
.Offset(0, 2).FormulaR1C1 = "=RC[-2]+RC[-1]"
End With
End If
End If
End If
End Sub
Thanks,
Rob