VBA Code Loop Through Data Validation List and copy returned values to another sheet

MTS26

New Member
Joined
Oct 15, 2018
Messages
7
I have a worksheet, "CMJ", that extracts data from "sheet 3" based on a name from a data validation range, on the "CMJ" Sheet. The extracted data is then run through additional equations, on "CMJ" Sheet and outputs new data that I want to copy and paste on another sheet, "DataSheet". The data validation, "Athlete_List", is on CMJ, cell N7. The values I want to copy are on "CMJ" cells T3 to AH3, and I want to copy them to "DataSheet", starting in cell A2, and pasting in the row on the bottom.

I had started with the idea that the code would compare the data validation list, "Athlete_List", with a specific list (This list is in column 7 on the "CMJ" Sheet) of names that should be selected from data validation list and data copied, to the "Data_Sheet" Sheet.

I hope that is enough detail. The code I currently have is below, but I cannot figure out the issue.

Sub Macro15()


Dim CMJ As Worksheet
Dim DataSheet As Worksheet
Dim Athlete_List As String
Dim rngitems As Range


Set CMJ = Sheet1
Set DataSheet = Sheet2
Set rngitems = Sheets("CMJ").Range("Athlete_List")


CMJ.Range("T3:AH3").ClearContents


For Each rngitems In Range("Athlete_List")


If Cells(i, 7) = Athlete_List Then
Range(Cells(i, 7), Cells(i, 27)).Copy
DataSheet.Select
Range("A200").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
CMJ.Select
Next rngitems
End If

Next i


CMJ.Select


Range("N7").Select


End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

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