Recordset - Urgent help need

T

Tim

Hi folks,

I have the following data (partial data - Total over 2000 records.) in excel
spreadsheet - sheet1. I would like to select top 10 of sales and multiply
the commission by 1.05 in ado recordset and update the commision column.
Please help.

Thanks in advance.
Tim.

Name Sales Commission
Pete 1000 40
John 500 20
Dave 1900 76
Mary 566 22.64
 
R

ryguy7272

Maybe something like this...

Sub Macro1()

Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1:C11").Select
Selection.Copy
Range("E1").Select
ActiveSheet.Paste
Range("H2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[-1]*1.05"
Range("H2").Select
Selection.AutoFill Destination:=Range("H2:H11")
Range("H2:H11").Select
End Sub

Regards,
Ryan---

PS, a Pivot Table will give you the top 10 as well...
 
T

Tim

Hi ryguy7272,

Thanks for your code but I can't use it because I can't change the order.
It links to orher spreadsheet and I can't add any sheet neither because it is
protected. Therefore, I think ado recordset will be my only choice. Could
you show me how to use ado recordset?

Thanks in advance.
Tim.

ryguy7272 said:
Maybe something like this...

Sub Macro1()

Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1:C11").Select
Selection.Copy
Range("E1").Select
ActiveSheet.Paste
Range("H2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[-1]*1.05"
Range("H2").Select
Selection.AutoFill Destination:=Range("H2:H11")
Range("H2:H11").Select
End Sub

Regards,
Ryan---

PS, a Pivot Table will give you the top 10 as well...

--
RyGuy


Tim said:
Hi folks,

I have the following data (partial data - Total over 2000 records.) in excel
spreadsheet - sheet1. I would like to select top 10 of sales and multiply
the commission by 1.05 in ado recordset and update the commision column.
Please help.

Thanks in advance.
Tim.

Name Sales Commission
Pete 1000 40
John 500 20
Dave 1900 76
Mary 566 22.64
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top