Consulting

Results 1 to 2 of 2

Thread: Help with userform

  1. #1
    VBAX Newbie
    Joined
    May 2015
    Posts
    1
    Location

    Help with userform

    Hello i have a little problems. I did form using userform and i wanted add new row below others but now my new record replaces the earlier record.


    Private Sub OKButton_Click()    
    Dim NextRow As Long
        
        Sheets("Lokale").Activate
        
        If TextLokal.Text = "" Then
            MsgBox "musisz podac dane"
            TextName.SetFocus
            Exit Sub
        End If
     
        'Range("B25").Select
        
        'NextRow = Application.WorksheetFunction.Count(Range("B:B")) + 1
        NextRow = ActiveCell.Row
        'Cells(y, x)
        Cells(NextRow, 2) = TextLokal.Text
        Cells(NextRow, 3) = TextNazwa.Text
        Cells(NextRow, 4) = TextUlica.Text
        Cells(NextRow, 5) = TextKodPocztowy.Text
        Cells(NextRow, 6) = TextMiasto.Text
        Cells(NextRow, 7) = TextIloscOsob.Text
        Cells(NextRow, 8) = TextRyczaltZW.Text
        Cells(NextRow, 9) = TextRyczaltCW.Text
        Cells(NextRow, 10) = TextPowierzchniaLokalu.Text
        Cells(NextRow, 11) = TextUdzial1.Text
        Cells(NextRow, 12) = TextPowierzchniaCalkowita.Text
        Cells(NextRow, 13) = TextUdzial2.Text
        Cells(NextRow, 14) = TextEmail.Text
        NextRow = NextRow + 1
        'TextLokal.Text = ""
        TextLokal.SetFocus
        
    End Sub

    Can someone help me ?? i Want add new record below others

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

    NextRow = Range("B" & rows.Count).End(xlUp).Offset(1).row

Posting Permissions

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