Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding cells after border

Status
Not open for further replies.

lbunch

Programmer
Sep 5, 2006
120
US
I need for the code below to add all of the cells to row 69 in the D column after the bordered P2 row is found and place the results in cell O3. Can someone help me - I think I have most of it except for the last line of the code below. Thanks in advance.

Public const Sales_Units_column = "03"


Public Sub SalesUntColumnAfterP2()
Dim P5Row As Long
'Get P5 Row
For P5Row = Me.dataStartsIndex To engine.template.lastDataRow
If cells(P2Row, SALES_UNITS_COLUMN).Borders(xlEdgeTop). _
LineStyle = xlDouble Then
Exit For
End If
Next P5Row
'[]
'Change formulas starting with the row after the P2 row
Dim range_ As String
Dim i As Integer
For i = P5Row + 1 To engine.template.lastDataRow
range_ = SALES_UNITS_COLUMN & i

I believe this needs to be changed:

templateSheet.Range(range_).Formula = "=W" & 300 + i
Next i
End Sub
 

Hi,
Code:
Public Const Sales_Units_column = 3

Public Sub SalesUntColumnAfterP2()
    Dim P5Row As Long
    'Get P5 Row
    For P5Row = Me.dataStartsIndex To engine.template.lastDataRow
        If Cells(P2Row, Sales_Units_column).Borders(xlEdgeTop). _
            LineStyle = xlDouble Then
            Exit For
        End If
    Next P5Row
'[]
    'Change formulas starting with the row after the P2 row
    
    Dim i As Integer
    For i = P5Row + 1 To engine.template.lastDataRow
        templateSheet.Cells(i, Sales_Units_column).Formula = "=W" & 300 + i
    Next i
End Sub


Skip,

[glasses] [red][/red]
[tongue]
 
What is this piece of the code doing?

templateSheet.Cells(i, Sales_Units_column).Formula = "=W" & 300 + i
Next i
 

putting a formula into a cell in the specified sheet.

What did you think it was?

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top