2009/07/27: NextEmptyCell(): Selects (or indicates) next row with empty cell (downwards):
2 alternatives: The first uses the End(xlDown) feature of Excel, the second checks every cell by using an variant array.
Sub NextEmptyCell1() With Selection 'next or 2nd next row empty? - choose it! If .Offset(1, 0) = "" Or .Offset(2, 0) = "" Then b = .Offset(2 + (.Offset(1, 0) = ""), 0).Row Else b = .Offset(-(.Offset(0, 0) = ""), 0).End(xlDown).Offset(1, 0).Row End If 'display row and/or select cell MsgBox "Row " & b Cells(b, .Column).Select End With End Sub Sub NextEmptyCell2(Optional n As Long = 1) 'returns the n-th empty cell Dim a rs = Cells.Rows.Count With Selection a = Range(Cells(1, .Column), Cells(rs, .Column)) For i = .Row + 1 To rs If a(i, 1) = "" Then j = j& + 1: If j = n Then Exit For Next MsgBox "Row " & i Cells(i, .Column).Select End With End Sub
2008/03/05: SheetMgr(): Deletes a sheet by name and adds it new or copies it from another:
Sub SheetMgr(sName As String, Optional Arg2 As String = "") 'SheetMgr "XY" deletes Sheet XY (if possible) 'SheetMgr "XY", "+" deletes Sheet XY, adds it again as new XY 'SheetMgr "XY", "AB" deletes Sheet XY, copies it new from Sheet AB Application.DisplayAlerts = False On Error Resume Next: Sheets(sName).Delete: On Error GoTo 0 Application.DisplayAlerts = True Select Case Arg2 Case Is = "+": Sheets.Add.Name = sName Case Is > "": Sheets(Arg2).Copy After:=Sheets(Arg2): _ ActiveSheet.Name = sName End Select End Sub