|
'------------------------------------------'
Private Sub btnSave_Click()
'------------------------------------------
Dim id As String
Dim sName As String
Dim sProduct As String
Dim iSales As Long
id = Me.txtID.Text
sName = Me.txtName.Text
sProduct = Me.txtProduct.Text
iSales = CLng(Me.txtSales.Text)
Dim rngCell As Range
' 해당 id 찾기
Set rngCell = Worksheets("Sheet1").Columns("A:A").Find( _
what:=id, lookat:=xlWhole, MatchCase:=False)
' 해당 id가 있으면
If Not rngCell Is Nothing Then
With rngCell.End(xlToRight).Offset(0, 1) '오른쪽 끝-> 다음 셀
.Value = sProduct
.Offset(0, 1).Value = iSales '오른쪽 다음 셀
End With
Else '해당 사번으로 최초 입력되는 경우
'마지막 행 다음 행에 배열로 값 넣기
Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(1, 4).Value = _
Array(id, sName, sProduct, iSales)
End If
End Sub
|
|