I'm trying to shoehorn one macro into another using the select case method:
The green part of the first macro works, and prompted me to expand the macro. The red part of the macro only works on some sheets. I kept the green part in case there is something important there.
The red part gets the input from the second macro, which also works (or good enough
)
The green part of the first macro works, and prompted me to expand the macro. The red part of the macro only works on some sheets. I kept the green part in case there is something important there.
The red part gets the input from the second macro, which also works (or good enough

- Could a kind soul please point out where I messed up with the red part?
Code:
Sub importerTotalsummer()
[COLOR="Green"]
WB1 = ActiveWorkbook.Name
Workbooks.Open Filename:= _
"C:\Users\David\Documents\korrekt volum - Kopi.xls", _
UpdateLinks:=0
WB2 = ActiveWorkbook.Name
WBname = "[" & WB2 & "]"
'Return to Master workbook
Workbooks(WB1).Activate
ActiveWorkbook.Unprotect
For i = 1 To 5
Select Case i
Case 1: wsname = "alfa"
Case 2: wsname = "beta"
Case 3: wsname = "charlie"
Case 4: wsname = "delta"
Case 5: wsname = "echo"
End Select
On Error Resume Next
If Worksheets(wsname).Name = "" Then
Sheets.Add(After:=Sheets(Sheets.Count)).Name = wsname
End If
Workbooks(WB1).Sheets(wsname).Cells.ClearContents
Workbooks(WB2).Sheets(wsname).Range("A1:af404").Copy _
Workbooks(WB1).Sheets(wsname).Range("A1")
Cells.Replace what:=WBname, replacement:=""
Next
Workbooks(WB2).Saved = True
Workbooks(WB2).Close[/COLOR]
[COLOR="Red"]Workbooks(WB1).Activate
For i = 1 To 8
Select Case i
Case 1: wsname = "foxtrot"
Case 2: wsname = "golf"
Case 3: wsname = "hotel"
Case 4: wsname = "india"
Case 5: wsname = "juliet"
Case 6: wsname = "kilo"
Case 7: wsname = "lima"
Case 8: wsname = "mike"
End Select
Workbooks(WB1).Sheets(wsname).Range("c4:c260").Select
Selection.Copy
Workbooks(WB1).Sheets(wsname).Range("e4").End(xlToRight).Offset(0, 1).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Next
End Sub[/COLOR]
Code:
Sub Kopiertest()
Range("c4:c260").Select
Selection.Copy
Range("e4").End(xlToRight).Offset(0, 1).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub