Hey All,
Part of my code is taking info from a sheet and pasting it into the header of a corresponding template sheet in the same workbook. I'm trying to paste only values that end in a 2 to one cell and only values that end in a 1 to another cell.
For some reason, my first header will paste correctly, but the following loops through the workbook will always defer to the "else" part of my loop.
Code:
Sub Header()Dim Names As Range, name As Range, sh As Worksheet, shdest As Worksheet, rn As Range, k As Long
Dim x As Long, wkshtcount As Long
wkshtcount = (ActiveWorkbook.Worksheets.Count - 1) / 2
For x = 1 To wkshtcount
Set sh = ThisWorkbook.Sheets(x + 1)
Set shdest = ThisWorkbook.Sheets(sh.name & (x + 1))
Set rn = sh.UsedRange
Set Names = sh.Range("A2:A" & Range("A1").End(xlDown).Row)
n = 0
For Each name In Names
If name.Offset(1, 0) <> name And name Like "*2" Then
shdest.Range("D7") = name
Else: shdest.Range("D8") = name
End If
Next name
shdest.Range("D9") = sh.Range("E2")
shdest.Range("D5") = sh.Range("G2")
shdest.Range("G5") = sh.Range("D2")
shdest.Range("G6") = sh.Range("F2")
Set name = Nothing
Next x
End Sub