Generate separate new sheets, based on a list of unique values (Macro help)

QA_Andre

New Member
Joined
Oct 10, 2022
Messages
2
Office Version
  1. 365
I'm trying to generate new separate reports(Sheets), based on a list of unique values.
And the reports/sheets will need to include value from the same row in the list.

"Serial #1"-column can provide the names of the new reports/sheets.

* Image 001 - The list of random values (Could be unique, and some may be identical. Such as "DATE", and "SIGN")
* Image 002 - The report. One report contains only the values from one row. The next report will get it's values from the row beneath.
* Only the orange columns needs to be included in the reports/sheets.

Can somone please help with this challenge? A macro that could perform this task for me, would literally save me days and days of work. It would be highly appreciated :)
 

Attachments

  • 002.JPG
    002.JPG
    54.7 KB · Views: 25
  • 001.JPG
    001.JPG
    201.8 KB · Views: 24

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi and welcome to MrExcel!


Try this:

VBA Code:
Sub Generate_separate_new_sheets()
  Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
  Dim i As Long
  
  Application.ScreenUpdating = False
  
  Set sh1 = Sheets("Index")
  Set sh2 = Sheets("Report")
  
  For i = 9 To sh1.Range("C:C").Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row
    sh2.Copy after:=Sheets(Sheets.Count)
    Set sh3 = ActiveSheet
    '
    sh3.Name = sh1.Range("C" & i).Value                 'Serial #1"-column can provide the names of the new sheets
    '
    sh3.Range("C18").Value = sh1.Range("C" & i).Value   'serial
    sh3.Range("C19").Value = sh1.Range("D" & i).Value   'serial 2
    sh3.Range("C22").Value = sh1.Range("I" & i).Value   'date
    sh3.Range("F22").Value = sh1.Range("J" & i).Value   'sign
  Next
  
  Application.ScreenUpdating = True
  MsgBox "Reports generated!"
End Sub


HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Generate_separate_new_sheets) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for.
If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
Solution
Hi and welcome to MrExcel!


Try this:

VBA Code:
Sub Generate_separate_new_sheets()
  Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
  Dim i As Long
 
  Application.ScreenUpdating = False
 
  Set sh1 = Sheets("Index")
  Set sh2 = Sheets("Report")
 
  For i = 9 To sh1.Range("C:C").Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row
    sh2.Copy after:=Sheets(Sheets.Count)
    Set sh3 = ActiveSheet
    '
    sh3.Name = sh1.Range("C" & i).Value                 'Serial #1"-column can provide the names of the new sheets
    '
    sh3.Range("C18").Value = sh1.Range("C" & i).Value   'serial
    sh3.Range("C19").Value = sh1.Range("D" & i).Value   'serial 2
    sh3.Range("C22").Value = sh1.Range("I" & i).Value   'date
    sh3.Range("F22").Value = sh1.Range("J" & i).Value   'sign
  Next
 
  Application.ScreenUpdating = True
  MsgBox "Reports generated!"
End Sub


HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Generate_separate_new_sheets) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for.
If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
You, dear Sir, have saved my life :)

Thank you so much, DanteAmor. Have a nice weekend!
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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