skip blank cell or not matched item when incerement in textbox on userfrom

leap out

Active Member
Joined
Dec 4, 2020
Messages
271
Office Version
  1. 2016
  2. 2010
Hello

I need fixing this problem . this trade/ 1000 will show when run the usefrom and incerement when run every time but if I have next empty cell in column E when incerement should move next empty cell and inceremen and somtimes there is item like debt or paid also should move after cells contains debt or paid .
in other meaning should if the whole row is empty then should directly incerement in next empty cell
but if the row contains data except column E then should skip this row and move next and if the whole row contains data then shold also skip and move next mpty row and incerement .
first when run from the first time and press copy
inv.JPG

after that will add some data
should incerement like this after press ok


inv2.JPG


and will add also data and should incerement like this
inv3.JPG


this the whole codes
VBA Code:
Private Sub CommandButton2_Click()

Dim ss As String, Nxt As String, LstRw As Long


ss = "trade/ "

LstRw = Range("E" & Rows.Count).End(xlUp).Row

If LstRw = 1 Then
    Nxt = ss & 1000
    Else
    Nxt = ss & Right(Cells(LstRw, 5).Value, 4) + 1
End If

Me.TextBox1 = Nxt

Cells(LstRw + 1, 5).Value = Nxt

End Sub


Private Sub UserForm_Initialize()

Dim ss As String, Nxt As String, LstRw As Long


ss = "trade/ "
'
LstRw = Range("E" & Rows.Count).End(xlUp).Row

If LstRw = 1 Then
    Nxt = ss & 1000
    Else
    On Error Resume Next
    Nxt = ss & Right(Cells(LstRw, 5).Value, 4) + 1
End If

Me.TextBox1 = Nxt
    
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top