get conditional lastrow value

Viewed 21

here I have serial number in textbox (txt_Rec) from worksheet("Sale") lastrow.

Now i want to get conditional values in textbox (txt_Rec), if i select "Sale" from combobox(Me.cmb_Type)dropdown list then i want worksheet("Sale") lastrow serial number in textbox (txt_Rec) and if i select "Purchase" from combobox(cmb_Type)dropdown list then i want worksheet("Purchase") lastrow serial number in textbox (txt_Rec).

 Private Sub UserForm_Initialize()
 Application.ScreenUpdating = False
 Dim sh As Worksheet
 Set sh = ThisWorkbook.Sheets("Sale")
 Dim lastrow As Long
 lastrow = Application.WorksheetFunction.CountA(sh.Range("A:A"))
 Me.txt_Rec.Value = lastrow

 ``` dropdown for Item type ```

 With Me.cmb_Type
    .Clear
    .AddItem ""
    .AddItem "Sale"
    .AddItem "Purchase"
    End With
    End Sub
0 Answers
Related