PDA

View Full Version : Help with userform



Pjk
05-29-2015, 04:34 AM
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

Kenneth Hobs
05-29-2015, 08:22 AM
Welcome to the forum!


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