Making sheet from 2 different tables

Dalacarelia

New Member
Joined
Apr 12, 2012
Messages
7
Hello

My Macro problem to solve is like this

I have a One Sheet with name "
Input_Sheet "

list 4 colums wide

Col1 (A) Defines name "PeterE" up to 50 names
Col2 (B) ( DefineType) GG or YRK

I have 2 TemplateSheet "GGTemplate and YRKTemplate and i need excel to make copy of the sheet for the right Type .


If its magic i will have 4 new sheets from 2 different templates and the nametable are sorted i alfabetic order colum A

My in my file i have 4 sheets with other information too so the new sheets need tobe added last
I have a solution for 1 Sheet but not with combo
<strike>
</strike>

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Colum A ( After macro runs alfabetic order ) [/TD]
[TD]Colum B[/TD]
[/TR]
[TR]
[TD]
Name
<strike></strike>
[/TD]
[TD]<strike></strike><strike></strike>Type
[/TD]
[/TR]
[TR]
[TD]
PeterZ
<strike></strike>
[/TD]
[TD]GG[/TD]
[/TR]
[TR]
[TD]
PeterK
<strike></strike>
[/TD]
[TD]YRK[/TD]
[/TR]
[TR]
[TD]
PeterM
<strike></strike>
[/TD]
[TD]GG[/TD]
[/TR]
[TR]
[TD]
PeterE
[/TD]
[TD]YRK[/TD]
[/TR]
</tbody>[/TABLE]











Macro i need to fix

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif] [FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Sub Mixa_ihopGG()
'
Columns("A:C").Select
ActiveWorkbook.Worksheets("
Input_Sheet
).AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("
Input_Sheet
").AutoFilter.Sort.SortFields.Add2 Key _
:=Range("A1:A100"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("
Input_Sheet
").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A2").Select

Dim sh1 As Worksheet, sh2 As Worksheet, c As Range
Set sh1 = Sheets("
GGTemplate
"
)
Set sh2 = Sheets("Input_Sheet")
For Each c In sh2.Range("A2", sh2.Cells(Rows.Count, 1).End(xlUp))
sh1.Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = c.Value
Next[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif][/FONT]
[/FONT][FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
[/FONT]
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I took my Coke and use the time and i find a solution

And here we go

Dim ws As Worksheet, Ct As Long, c As Range
Set ws = Worksheets("Mallblad_YRK")
Application.ScreenUpdating = False
For Each c In Sheets("Indata_bladet").Range("E2:E20")
If c.Value <> "" Then
ws.Copy after:=Sheets(Sheets.Count)
ActiveSheet.Name = c.Value
Ct = Ct + 1
End If
Next c
If Ct > 0 Then
MsgBox Ct & " Nya blad ?r skapade fr?n Yrklistan"
Else
MsgBox "Inga Yrknamn"
End If
Application.ScreenUpdating = True

Dim ws2 As Worksheet, Ct2 As Long, c2 As Range
Set ws2 = Worksheets("Mallblad_GG")
Application.ScreenUpdating = False
For Each c2 In Sheets("Indata_bladet").Range("A2:A20")
If c2.Value <> "" Then
ws2.Copy after:=Sheets(Sheets.Count)
ActiveSheet.Name = c2.Value
Ct2 = Ct2 + 1
End If
Next c2
If Ct2 > 0 Then
MsgBox Ct2 & " Nya blad ?r skapade fr?n GG listan"
Else
MsgBox "Inga GG namn i listan "
End If
Application.ScreenUpdating = True




It works out fine
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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