• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need to understand in detail (With function)

If Int((row - 10) / 5) Mod 2 = 0 Then
Cells(row, 3).Interior.Color = 12632256
----------------------------------------------------
With Cells(reason_count + 11, 2)
.Value = "Total Append Assets"
.Font.Bold = True
End With
----------------------------------------------------
With Cells(reason_count + 11, 5)
.Formula = "=sum(e10:e" & (reason_count + 9) & ")"
.Borders.LineStyle = xlContinuous
End With
----------------------------------------------------
With Cells(reason_count + 15, 7)
.Formula = "=SUM($D" & (reason_count + 15) & ":F" & (reason_count + 15) & ")"
.Borders.LineStyle = xlContinuous
.Font.Bold = True
.Interior.Color = 16764057
End With
 
This is easier to explain if we assume that the reason_count variable is equal to 1 currently.
If Int((row - 10) / 5) Mod 2 = 0 Then 'The Mod function take a number and a divisor, and returns the remainder. For every set of 5 rows, this evaluates to true. Easiest to see if you put this formula in A1 and copy down

'=MOD(INT((ROW()-10)/5,2)
Cells(row, 3).Interior.Color = 12632256 'Set the color of the cell backgroun
----------------------------------------------------
With Cells(reason_count + 11, 2) 'With the cell in row 12, column 2 (aka B12)...
.Value = "Total Append Assets" '...Set a value in the cell, ...
.Font.Bold = True 'and make the font bold
End With
----------------------------------------------------
With Cells(reason_count + 11, 5) 'With the cell in row 12, column 5 (aka E12)
.Formula = "=sum(e10:e" & (reason_count + 9) & ")" '...put the formula "=SUM(E10:E10)"
.Borders.LineStyle = xlContinuous 'and give the cell a border
End With
----------------------------------------------------
With Cells(reason_count + 15, 7) 'With the cell in row 16, column 7 (aka G16)
.Formula = "=SUM($D" & (reason_count + 15) & ":F" & (reason_count + 15) & ")" '...put formula "=SUM($D16:F16)"
.Borders.LineStyle = xlContinuous 'and give it a border...
.Font.Bold = True 'with the font bold...
.Interior.Color = 16764057 'and a specific color background
End With
 
Back
Top