Copy Top 10 Values With Corresponding Names Into Another Sheet Excel VBA

taccoo73

New Member
Joined
Feb 14, 2014
Messages
21
Hi All;

First of all, thanks again for your time and help in advance. Here I am with another issue which I’m failing to see where the problem is.

Code below finds the highest 10 values in a range (column I) and copies them into another sheet. Part with the top 10 values and copying them is working nicely. But when I’m trying to bring the corresponding names for those values (column B) I’m hitting the wall. Code below says “Object Variable or With Block Variable not set”.

Code:
Sub top10()
 
Dim rngValues As Range
Dim rngNames As Range
Dim i As Integer
Dim r As Integer
Dim j As Long
Dim lrow As Long
Dim l As String
 
Dim rptdate As String
Dim CIOfile As String
Stop
rptdate = Range("B3")
CIOfile = "CIO Mng" & " " & rptdate & ".xlsm"
 
Set rngValues = Workbooks(CIOfile).Sheets("Rep").Range("I11:I310")
 
l = 0
j = 0
r = 19
 
For i = 1 To 10
 
    j = Application.WorksheetFunction.Large(rngValues, i)
    Set rngNames = rngValues.Find(j)
    lrow = rngNames.Row
    l = Cells(lrow, "B").Value
    Cells(r, "H") = j
    Cells(r, "G") = l
    r = r + 1
Next i
 
End Sub

Any help will be appreciated.

Kind Regards;

tac
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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