Hi
I have a textbox (txtName) and a combobox (cboDept) in a form. cboDept contents come from sheet1 column A Cell range A2:A8 .I also have additional data in cells B2:E8 in sheet1. I add names in sheet2 cell A2 and their working department in sheet2 B2,
for example i add Smith and Financial in A2 and B2 of sheet2 .Assume Financial is in sheet1 A5 Now I want contents of B5:E5 in sheet 1 Paste into C2:F2 in sheet 2
I even tried to copy after names introduction had been done with copy or Update code but couldn't. Please help to fix the codeCode:Private Sub cmdAdd_Click() Dim LastRow As Long Dim ws As Worksheet Dim rng As Range Set ws = Sheets("sheet2") LastRow = ws.Range("A" & Rows.Count).End(xlUp).row + 1 ws.Range("A" & LastRow).Value = Me.txtName.Text ws.Range("A" & LastRow).Offset(0, 1).Value = Me.cboDept.Text With cboDept_Change Select Case .Value Case 1: Set rng = Range("B2:E2") End Select End With Sheets("Sheet1").rng.Copy = Sheets("Sheet2").Range("C2:F2") ' Clear the form Me.txtName.Text = "" Me.txtEN.Text = "" Me.cboShift.Text = "" End Sub
Thanks




Reply With Quote
