Results 1 to 10 of 10

Add data to range using MsgBox

Threaded View

  1. #1
    Registered User
    Join Date
    04-25-2008
    Posts
    6

    Smile Add data to range using MsgBox

    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
    Last edited by rylo; 04-25-2008 at 04:33 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1