VBA - create new sheet from a template

traxman

New Member
Joined
Oct 3, 2019
Messages
6
Hi

I am asking for your help for a VBA code which create new sheets from a template sheet.

I have already found and modified which works well :

Code:
<code class="hljs vbscript">Sub CreeOnglets()
   Application.ScreenUpdating = False
   supOnglets
   Set bd = Sheets("bd")
   bd.[A1].CurrentRegion.Sort Key1:=bd.Range("A2"), Order1:=xlAscending, Header:=xlGuess
   ligBD = 2
   Do While ligBD <= bd.[A65000].End(xlUp).Row
       nom = bd.Cells(ligBD, 1)       ' Premier nom
       Sheets("modèle").Copy After:=Sheets(Sheets.Count)
       ActiveSheet.Name = "F_" & nom
       Set fiche = Sheets("F_" & nom)
       fiche.Range("B3").Value = nom
       fiche.Range("b4").Value = bd.Cells(ligBD, "B")
       ligBD = ligBD + 1
    Loop
End Sub
Sub supOnglets()
  Application.DisplayAlerts = False
  For s = Sheets.Count To 1 Step -1
     If Left(Sheets(s).Name, 2) = "F_" Then Sheets(s).Delete
  Next s
End Sub
Sub exportOnglets()
    CheminAppli = ThisWorkbook.Path
    Application.DisplayAlerts = False
    For i = 1 To Sheets.Count
        If Left(Sheets(i).Name, 2) = "F_" Then
          Sheets(i).Select
          nonglet = ActiveSheet.Name
          ActiveSheet.Copy
          ActiveWorkbook.SaveAs Filename:=CheminAppli & "\" & nonglet
          ActiveWindow.Close
        End If
    Next i
End Sub
Sub consolideOngletsBD()
    ligBD = 2
    Set bd = Sheets("bd")
    For f = 1 To Sheets.Count
        If Left(Sheets(f).Name, 2) = "F_" Then
           bd.Cells(ligBD, "A") = Sheets(f).[B3]
           ligBD = ligBD + 1
        End If
    Next f
End Sub</code>

but the problem is that with this code the new entries are organized in rows (A, A2, A3 etc...), while I need to transform it into columns (A1, B1, C1 etc...)

How can I transform this code to select the next entry in the next column and not in the next row ?

Thank you very much for your help

Anthony
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Assuming you are talking about the first Sub out of the 4 you have posted, where should the value of B4 come from if the sheet names are coming from A1, B1 etc?
 
Upvote 0
Thank you very much for your help :)

It is not very easy to explain for me (as I am neither english native nor an excel expert).

I use this code found in the web (http://boisgontierjacques.free.fr/pages_site/cellules.htm)

The here a database in sheet "BD", with the last names (column A), first names (in B), adrdess (in C)...

A sheet called "modèle" corresponds to the template




The template sheet:



I hope I have been clear enough. If not, how can I provide you the excel file ?

Thank you very much again

Anthony
 
Last edited by a moderator:
Upvote 0
Sorry I don't know that I couldn't add pictures, so here is the two pictures that I wanted to share with you





Thank you again (and sorry for my mistake)
 
Upvote 0
Okay thank you

I try to add above screenshots of the Excel sheets and try to explain my problem

Thank you

Anthony
 
Upvote 0
Do you still want one sheet per person?
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

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