Basically it's a continuation of previously asked question (ref: How to copy all sheet names to a particular sheet in the same workbook?) for which I got my answer but after adding one more statements I stuck with two problems: 1) With current statements' order it shows only as if it executed code for one sheet and not for columns but sometimes when I try to mix If statements it works which is weird. So the question is: Does the order matter here and if yes in which order if should come? 2) Since IF statements are all the same for all thens I would like to combine them but dont know if it's possible at all Here's code:
Sub passport_combining ()
With ThisWorkbook.Sheets("MainSheet")
For Each wsheet In ThisWorkbook.Sheets
If wsheet.Name <> "MainSheet" Then
Set nextEntry_FTE_quantity = .Cells(.Rows.Count, "K").End(xlUp).Offset(1, 0)
Set nextEntry_nonrecurring_expenses = .Cells(.Rows.Count, "S").End(xlUp).Offset(1, 0)
Set nextEntry_initiative_type = .Cells(.Rows.Count, "Q").End(xlUp).Offset(1, 0)
Set nextEntry = .Cells(.Rows.Count, "G").End(xlUp).Offset(1, 0)
If IsError(Application.Match(wsheet.Name, .Range("G:G"), 0)) Then nextEntry.Value = wsheet.Name
If IsError(Application.Match(wsheet.Name, .Range("G:G"), 0)) Then nextEntry_FTE_quantity.Value = wsheet.Range("BH16").Value
If IsError(Application.Match(wsheet.Name, .Range("G:G"), 0)) Then nextEntry_initiative_type.Value = wsheet.Range("K8").Value
If IsError(Application.Match(wsheet.Name, .Range("G:G"), 0)) Then nextEntry_nonrecurring_expenses.Value = wsheet.Range("BH17").Value
End If
Next wsheet
End With
Thanks!