Hello,
I appeal to you, as after much searching and writing in forums and sites, nobody could help me.
My question is this:
I want to sort and copy data by predefined attribute (text) from one Sheet (Sheet2) to another (Sheet3), using a button that is located in Sheet1. Value at which will be sorting is defined by ComboBox.
ie I have a set of data stored in Sheet2 (village, municipality, district). When I click on the sort in Sheet1, all matches to the specified attribute to be copied together with the entire rows (line) and saved to a specified location on Sheet 3 - for example, the beginning of the record set C3.
This is the code I used, but I have two problems:
1. Code is activated only when the button is installed on the data sheet (Sheet2)
2. Data is written to Sheet3 only cell A1 (gives me an error when I try to change the address of the cell).
Here's the code:
Private Sub CommandButton1_Click()
Dim startRa As Range
Dim endRa As Range
Dim DataRowNum As Integer, SheetRowNum As Integer
Range(„A1″).Select
Cells.Find(What:=ComboBox1.Value, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Set startRa = ActiveCell
Do
Set endRa = ActiveCell
Cells.Find(What:=ComboBox1.Value, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Loop While ActiveCell.Row = endRa.Row + 1
Rows(startRa.Row & „:“ & endRa.Row).Select
Selection.Copy Destination:=Sheet3.Range(„a65536″).End(xlUp).Offset(1, 0)
End Sub
I would be very grateful if someone help me succeed
Bookmarks