ndouglas48
New Member
- Joined
- Sep 13, 2012
- Messages
- 29
I want to first start that I have read through and tried many of Ron Debruin's examples provided here and am still in need of major assistance. I am sure some of this code just needs to be tweeked a little but I have tried my best and have sadly failed.... Good thing there is a world of help here!
I currently have a file that possesses a table named "DataTable" on one sheet ("Program Data") that gives student information (ID, Name, e-mail. group, scores) and a second sheet ("Scores") that possesses a data validation cell (yellow cell) that has all ID values in a dropdown. When a student's ID is selected from the dropdown the other cells are populated via VLOOKUP formulas to display and chart that student's score data. Below is what these look like:
Thanks to a very kind friend I have the following Macro code that allows me to input a group value into an input box and will locate all instances of this group value in the DataTable and INDEX the ID values and cycle them through the validation cell to print all of these records. So each student can be handed a printout of their graphed scores and I can print these based on their groups (class period).
The kicker is now I am needing to do the exact same thing except email each student's their file as a PDF attachment. Administration is cracking down on paper usage. So, long story short I am needing a VBA Macro that when ran it will open the same input box and I will input the GROUP value I wish to email and it will find all instances in the DataTable, INDEX the ID value, place it in the data validation cell ("B4") so all VLOOKUP data will be updated, Create a PDF of the range ("A1:H20"), E-mail it to the e-mail address that is displayed in cell ("B2") which changes based on the ID value in B4, and loops through all instances where the GROUP value equals my inputted value. I do not need it to save the PDF files emailed or want to click send on all of the emails (have it send automatically).
I know that this is complex but I know someone out there can manage this and it would truly mean the world to me. Any any all help is greatly appreciated. Again, I believe that Ron Debruin's examples are a great starting point but I don't know how to incorporate my code/file to make this thing work.
I currently have a file that possesses a table named "DataTable" on one sheet ("Program Data") that gives student information (ID, Name, e-mail. group, scores) and a second sheet ("Scores") that possesses a data validation cell (yellow cell) that has all ID values in a dropdown. When a student's ID is selected from the dropdown the other cells are populated via VLOOKUP formulas to display and chart that student's score data. Below is what these look like:

Thanks to a very kind friend I have the following Macro code that allows me to input a group value into an input box and will locate all instances of this group value in the DataTable and INDEX the ID values and cycle them through the validation cell to print all of these records. So each student can be handed a printout of their graphed scores and I can print these based on their groups (class period).
Code:
[COLOR=#333333]Sub PRINT_GROUPS()[/COLOR]Dim ws As Worksheet
Dim Num As Variant
Set ws = ActiveSheet
showInputBox:
Num = Application.InputBox("Enter the GROUP value you wish to print.")
If Num = False Then
Exit Sub
ElseIf IsNumeric(Num) = True Then
Num = Int(Num)
Else: Num = UCase(Num)
End If
For i = 4 To Worksheets("Program Data").Cells(Rows.Count, "D").End(xlUp).Row
If Worksheets("Program Data").Cells(i, "D") = Num Then
Worksheets("Scores").Cells(4, "B").Value = Worksheets("Program Data").Cells(i, "A")
ws.PrintOut , IgnorePrintAreas:=False
End If
Next i [COLOR=#333333]End Sub[/COLOR]
The kicker is now I am needing to do the exact same thing except email each student's their file as a PDF attachment. Administration is cracking down on paper usage. So, long story short I am needing a VBA Macro that when ran it will open the same input box and I will input the GROUP value I wish to email and it will find all instances in the DataTable, INDEX the ID value, place it in the data validation cell ("B4") so all VLOOKUP data will be updated, Create a PDF of the range ("A1:H20"), E-mail it to the e-mail address that is displayed in cell ("B2") which changes based on the ID value in B4, and loops through all instances where the GROUP value equals my inputted value. I do not need it to save the PDF files emailed or want to click send on all of the emails (have it send automatically).
I know that this is complex but I know someone out there can manage this and it would truly mean the world to me. Any any all help is greatly appreciated. Again, I believe that Ron Debruin's examples are a great starting point but I don't know how to incorporate my code/file to make this thing work.