Dear all,
I have a problem with the following macro:
Basically, I want to insert a static range that is located on a different sheet in every sheet within my loop. I am struggling how to "return" to the sheet within my loop after going to the sheet Overview.
Is it possible to build a named range and insert this named range?
Thanks in advance,
I have a problem with the following macro:
Code:
Sheets("X").SelectRange("A2").Select
ActiveCell.SpecialCells(xlLastCell).Select
LastCellData = ActiveCell.Address
LastRowNew = ActiveCell.Row
For Each ws In Worksheets
If (ws.Name <> "Overview") And (ws.Name <> "X") And (ws.Name <> "Y") And (ws.Name <> "Data") Then
ws.Activate
Columns("F:F").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbo
Range("B:B").Select
Selection.Copy
Range("F1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Overview").Select
Range("A2:A" & LastRowNew).Select
Selection.Copy
[B] Sheets(///the corresponding sheet within the loop///).Select[/B]
Range("A2").Select
ActiveSheet.Paste
End If
Next ws
End Sub
Basically, I want to insert a static range that is located on a different sheet in every sheet within my loop. I am struggling how to "return" to the sheet within my loop after going to the sheet Overview.
Is it possible to build a named range and insert this named range?
Code:
Sheets("X").SelectRange("A2").Select
ActiveCell.SpecialCells(xlLastCell).Select
LastCellData = ActiveCell.Address
LastRowNew = ActiveCell.Row
[B]Dim rangeCells = Range("A2:A" & LastRowNew).Values[/B]
For Each ws In Worksheets
If (ws.Name <> "Overview") And (ws.Name <> "X") And (ws.Name <> "Y") And (ws.Name <> "Data") Then
ws.Activate
Columns("F:F").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbo
Range("B:B").Select
Selection.Copy
Range("F1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A2").Select
[B] ActiveSheet.Paste /// How do I insert the named range here?[/B]
End If
Next ws
End Sub
Thanks in advance,