V
Vicky
Hi,
Help in this regards are welcome.
I have created a user form for which the coding has been done. The adjacent
cells are having formulas. Now i wish to fill the formulas of the adjacent
cells upto the last filled row whenever i press the add button.
For the ready ref. here is the coding of the User Form :
Private Sub cmdAdd_Click()
Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("DBASE")
irow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
If Trim(Me.txtInv.Value) = "" Then
Me.txtInv.SetFocus
MsgBox "Please enter the Invoice number"
Exit Sub
End If
ws.Cells(irow, 1).Value = Me.txtInv.Value
ws.Cells(irow, 2).Value = Me.txtDate.Value
ws.Cells(irow, 3).Value = Me.cboCust.Value
ws.Cells(irow, 4).Value = Me.cboImCode.Value
ws.Cells(irow, 5).Value = Me.txtQty.Value
ws.Cells(irow, 6).Value = Me.txtPack.Value
ws.Cells(irow, 7).Value = Me.txtRate.Value
ws.Cells(irow, 8).Value = Me.txtContainer.Value
ws.Cells(irow, 9).Value = Me.txtSeal.Value
ws.Cells(irow, 10).Value = Me.optAir.Value
ws.Cells(irow, 10).Value = Me.optSea.Value
Me.txtInv.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 0).Value
Me.txtDate.Value = Format(Date, "dd/mm/yyyy")
Me.cboCust.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 2).Value
Me.cboImCode.Value = ""
Me.txtQty.Value = ""
Me.txtPack.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 5).Value
Me.txtRate.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 6).Value
Me.txtContainer.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 7).Value
Me.txtSeal.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 8).Value
If optSea = True Then
ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 9).Value = "SEA"
ElseIf optAir = True Then
ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 9).Value = "AIR"
End If
Me.txtInv.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub Lable_Click()
End Sub
Private Sub UserForm_queryclose(cancel As Integer, _
closemode As Integer)
If closemode = vbFormControlMenu Then
cancel = True
MsgBox "Please use the button"
End If
End Sub
Private Sub UserForm_Initialize()
Dim cCust As Range
Dim cParts As Range
Dim ws As Worksheet
Set ws = Worksheets("DBASE")
Set wss = Worksheets("Cust Master")
Set wsss = Worksheets("Im Master")
Me.txtInv.SetFocus
For Each cCust In wss.Range("CustID")
With Me.cboCust
.AddItem cCust.Value
.List(.ListCount - 1, 1) = cCust.Offset(0, 1).Value
End With
Next cCust
For Each cParts In wsss.Range("PartsID")
With Me.cboImCode
.AddItem cParts.Value
.List(.ListCount - 1, 1) = cParts.Offset(0, 1).Value
End With
Next cParts
Me.txtInv.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 0).Value
Me.txtDate.Value = Format(Date, "dd/mm/yyyy")
Me.cboCust.Value = ""
Me.cboImCode.Value = ""
Me.txtQty.Value = ""
Me.txtPack.Value = ""
Me.txtRate.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 6).Value
Me.txtContainer.Value = ""
Me.txtSeal.Value = ""
Me.txtInv.SetFocus
End Sub
====================================================
Looking forward for the valuable suggestion in this regard.
Help in this regards are welcome.
I have created a user form for which the coding has been done. The adjacent
cells are having formulas. Now i wish to fill the formulas of the adjacent
cells upto the last filled row whenever i press the add button.
For the ready ref. here is the coding of the User Form :
Private Sub cmdAdd_Click()
Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("DBASE")
irow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
If Trim(Me.txtInv.Value) = "" Then
Me.txtInv.SetFocus
MsgBox "Please enter the Invoice number"
Exit Sub
End If
ws.Cells(irow, 1).Value = Me.txtInv.Value
ws.Cells(irow, 2).Value = Me.txtDate.Value
ws.Cells(irow, 3).Value = Me.cboCust.Value
ws.Cells(irow, 4).Value = Me.cboImCode.Value
ws.Cells(irow, 5).Value = Me.txtQty.Value
ws.Cells(irow, 6).Value = Me.txtPack.Value
ws.Cells(irow, 7).Value = Me.txtRate.Value
ws.Cells(irow, 8).Value = Me.txtContainer.Value
ws.Cells(irow, 9).Value = Me.txtSeal.Value
ws.Cells(irow, 10).Value = Me.optAir.Value
ws.Cells(irow, 10).Value = Me.optSea.Value
Me.txtInv.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 0).Value
Me.txtDate.Value = Format(Date, "dd/mm/yyyy")
Me.cboCust.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 2).Value
Me.cboImCode.Value = ""
Me.txtQty.Value = ""
Me.txtPack.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 5).Value
Me.txtRate.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 6).Value
Me.txtContainer.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 7).Value
Me.txtSeal.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 8).Value
If optSea = True Then
ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 9).Value = "SEA"
ElseIf optAir = True Then
ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 9).Value = "AIR"
End If
Me.txtInv.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub Lable_Click()
End Sub
Private Sub UserForm_queryclose(cancel As Integer, _
closemode As Integer)
If closemode = vbFormControlMenu Then
cancel = True
MsgBox "Please use the button"
End If
End Sub
Private Sub UserForm_Initialize()
Dim cCust As Range
Dim cParts As Range
Dim ws As Worksheet
Set ws = Worksheets("DBASE")
Set wss = Worksheets("Cust Master")
Set wsss = Worksheets("Im Master")
Me.txtInv.SetFocus
For Each cCust In wss.Range("CustID")
With Me.cboCust
.AddItem cCust.Value
.List(.ListCount - 1, 1) = cCust.Offset(0, 1).Value
End With
Next cCust
For Each cParts In wsss.Range("PartsID")
With Me.cboImCode
.AddItem cParts.Value
.List(.ListCount - 1, 1) = cParts.Offset(0, 1).Value
End With
Next cParts
Me.txtInv.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 0).Value
Me.txtDate.Value = Format(Date, "dd/mm/yyyy")
Me.cboCust.Value = ""
Me.cboImCode.Value = ""
Me.txtQty.Value = ""
Me.txtPack.Value = ""
Me.txtRate.Value = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 6).Value
Me.txtContainer.Value = ""
Me.txtSeal.Value = ""
Me.txtInv.SetFocus
End Sub
====================================================
Looking forward for the valuable suggestion in this regard.