create worksheet and insert row

  • Thread starter Thread starter junx13
  • Start date Start date
J

junx13

hi,
having problems with this part of my function to open a new
worksheet if it's the first time it executes, and then write a new row.
and all subsequent times I execute it, it will write in another new row
of info.

All help appreciated!! Thanks
 
Private wksMyNewSheet As Worksheet

Sub test()
Dim i As Long

If wksMyNewSheet Is Nothing Then
Set wksMyNewSheet = Worksheets.Add
wksMyNewSheet.Name = "My New Sheet"
End If

With wksMyNewSheet
With .UsedRange
On Error Resume Next
i = 1: i = .Find("*", .Cells(1), xlFormulas, xlWhole, xlByRows,
xlPrevious).Row + 1
On Error GoTo 0
End With
.Cells(i, 1).Value = "New Entry: " & Format(Now(), "hh:mm:ss")
End With
End Sub
 
Back
Top