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

Abdo

Board Regular
Joined
May 16, 2022
Messages
201
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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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