how copy sorting data from sheet to nother based on combobox(not Active X)

Abdo

Board Regular
Joined
May 16, 2022
Messages
183
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
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
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
I hope somebody can fix the code .
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,214,402
Messages
6,119,301
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top