Hi
I have data in sheet1 start from A1:E and sheet 2 contains combobox not active X , when select combobox1 the name then should match with column A for sheet1 and copy data to sheet2 start from row 7 (A7:E)
row6 in sheet2 is the header, row1 in sheet1 is the header
here is the code
I hope somebody can fix the code .
I have data in sheet1 start from A1:E and sheet 2 contains combobox not active X , when select combobox1 the name then should match with column A for sheet1 and copy data to sheet2 start from row 7 (A7:E)
row6 in sheet2 is the header, row1 in sheet1 is the header
here is the code
VBA Code:
Private Sub WorkSheet_Change(ByVal Target As Range)
If combobox1.Value Then
Dim lastrow As Long
Dim sh1, sh2 As Worksheet
Set sh1 = sheet1
Set sh2 = sheet2
lastrow = sh1.Cells(Rows.Count, 1).End(xlUp).Row
sh1.Range("a1:E" & lastrow).Sort key1:=Range("a1:a" & lastrow), order1:=xlAscending, Header:=xlNo_
Copy sh2.Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
End Sub