Hi,
I'm trying to add data to a list in a range using a MsgBox. I need to look for the next empty row in the range and expand the range as necessary while not overwriting stuff below the current range. I have the code below which adds to the 'database', but doesn't look in the Range (Doc_List). SO I guess I need to insert the data rather than append in the range so any data below the range doesn't get overwritten.
Thanks
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Doc_soft")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 1).Row
'Check for a new doc
If Trim(Me.DocNum.Value) = "" Then
Me.DocNum.SetFocus
MsgBox "Enter Document or Software Information"
Exit Sub
End If
'copy the data from the msgbox to the database
ws.Cells(iRow, 1).Value = Me.DocNum.Value
ws.Cells(iRow, 2).Value = Me.DocTitle.Value
ws.Cells(iRow, 3).Value = Me.DocSoftRev.Value
ws.Cells(iRow, 4).Value = Me.DocStat.Value
'clear the data
Me.DocNum.Value = ""
Me.DocTitle.Value = ""
Me.DocSoftRev = ""
Me.DocStat = ""
End Sub
Bookmarks