Академический Документы
Профессиональный Документы
Культура Документы
ErrH:
MsgBox "It seems some file was missing. The data copy operation is not compl
ete."
Exit Sub
End Sub
Public Function LastRowInOneColumn(col)
'Find the last used row in a Column: column A in this example
'http://www.rondebruin.nl/last.htm
Dim lastRow As Long
With ActiveSheet
lastRow = .Cells(.Rows.Count, col).End(xlUp).Row
End With
LastRowInOneColumn = lastRow
End Function
--------------------------------------------------------------------------------
--------------------------------
'Loop for paste formula in blank cells till data avilable
Range( C2 ).Select
Do Until ActiveCell.Offset(0,-1).Value =
ActiveCell.FormulaR1C1 = =SUM(rc[-2]:rc[-1])
ActiveCell.Offset(1,0).Select
Loop
--------------------------------------------------------------------------------
--------------------------------------
'Loop to delete blank rows from the sheet
Range( C2 ).Select
Do Until ActiveCell. Value = End
If ActiveCell.value = then
Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(1,0).Select
End if
Loop
--------------------------------------------------------------------------------
--------------------------------------
Sub MakeCheckerboard()
Dim R As Long, C As Long
For R = 1 To 8
If WorksheetFunction.IsOdd(R) Then
For C = 2 To 8 Step 2
Cells(R, C).Interior.Color = 255
Next C
Else
For C = 1 To 8 Step 2
Cells(R, C).Interior.Color = 255
Next C
End If
Next R
Rows( 1:8 ).RowHeight = 35
Columns( A:H ).ColumnWidth = 6.5
End Sub
--------------------------------------------------------------------------------
------------------------------------------
Sub For_Loop_With_Step()
Dim lCount As Long, lNum As Long
MsgBox "The For loop made " & lNum & " loop(s). lNum is equal to " & lNum
End Sub
--------------------------------------------------------------------------------
----------------------------------
Sub CountFruit()
' Get the last row with text
Dim LastRow As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Dim i As Long, Total As Long
' Use LastRow in loop
For i = 2 To LastRow
' Check if cell has text "Orange"
If Cells(i, 1).Value = "Oranges" Then
' Add value in column B to total
Total = Total + Cells(i, 2).Value
End If
Next i
' Print total
Debug.Print "Total oranges sold was:"; Total
End Sub