Vba and userform for Extracting data from multiple sheets and into a table in a new sheet and then printed

shizu

New Member
Joined
Mar 22, 2018
Messages
7
Registration_NoFirst_NameOther_NameLast_name1st_CA2nd_CA3rd_CAExamTotalGradePositionAverage
9008MikeJoePeter6785677A270
9009LukeChanLee2463446D4
9010BlakeHarryBlake8866991A1
9011UgoKelechiAmadi6874566B2

<tbody>
</tbody>

I have between 10 to 12 sheets in a workbook containing students' results in the above format, each sheet is for a subject (For example Mathematics, English, Physics, Chemistry, Biology etc) and column 'exam' to 'Average' contains formulas.

Now I want to extract each student result (using the data from the column 'Registration_No' as the unique identifier) from all the sheets in the workbook into a new sheet that I can then print. I want a user-form which would serve like a search bar in which the 'Registration_no@ would be typed in and the result generated then the user can then print it.

Please who got ideas to help me out.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try this simple spreadsheet that just uses a lookup an needs no vba to accomplish
https://www.dropbox.com/s/ymg6b42i8x4yegi/Sample.xlsx?dl=0

Thanks for the effort, but it is not exactly what I was looking for, I want a situation whereby a third party can input the 'Registration_No' into a user-form and then click ok and the student's result would then be extracted into a new sheet for printing. This is to enable the user to be able to print each student result by inputting their Registration_No into the userform.

If this can't be possible with Excel any idea on other possible solution on how to extract each students result from all the sheets into a new sheet for printing
 
Upvote 0
OK have the user form input the registration number and then the result would be pasted into the lookup cell of the results sheet, unhide the results sheet, switch to the results sheet which has the lookups in and make it the active sheet, and then print the results sheet.
 
Upvote 0
Another option.
Put this in the userform module
Code:
Option Explicit
Dim Dic As Object

Private Sub ComboBox1_Change()
   Dim Ws As Worksheet
   
   Sheets("print").UsedRange.Offset(1).Clear
   For Each Ws In Worksheets
      If Not Ws.Name = "Print" Then
         If Ws.AutoFilterMode Then Ws.AutoFilterMode = False
         Ws.Range("A1").AutoFilter 1, Me.ComboBox1.Value
         Ws.AutoFilter.Range.Offset(1).SpecialCells(xlVisible).Copy Sheets("Print").Range("A" & Rows.Count).End(xlUp).Offset(1)
         Ws.AutoFilterMode = False
      End If
   Next Ws
   Sheets("Print").PrintOut
End Sub

Private Sub UserForm_Initialize()
   Dim Ws As Worksheet
   Dim Cl As Range
   
   Set Dic = CreateObject("scripting.dictionary")
   Sheets("Print").UsedRange.Offset(1).Clear
   For Each Ws In Worksheets
      For Each Cl In Ws.Range("A2", Ws.Range("A" & Rows.Count).End(xlUp))
         If Not Dic.exists(Cl.Value) And Not IsEmpty(Cl) Then Dic.Add Cl.Value, Nothing
      Next Cl
   Next Ws
   Me.ComboBox1.List = Dic.keys
End Sub
 
Upvote 0
So are you saying:
You enter 9010 into Userform Textbox1
Then you want script to search all sheets for the number 9010 in column A
If 9010 is found in Column A then copy that entire row into a new sheet named 9010

And do this on all sheets in the workbook

If this is not what you want then provide me with more details
 
Upvote 0
So are you saying:
You enter 9010 into Userform Textbox1
Then you want script to search all sheets for the number 9010 in column A
If 9010 is found in Column A then copy that entire row into a new sheet named 9010

And do this on all sheets in the workbook

If this is not what you want then provide me with more details

Yes that's what I want but the new sheet would be like a template like below
NameMicheal Joe PetersAttendance76 out of 82 daysTotal Average980
Registration_No9008Class Position7thNext Term Opening date6th September 2018
Subjects1st_CA2nd_CA3rd_CAExamTotalPositionGradeAverage
Mathematics555506512B45.8
English451405031C65
History36665801A66.5

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,757
Messages
6,126,693
Members
449,331
Latest member
smckenzie2016

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