Hey everyone,
I've created a simple For Loop thingy and one of the things it does is name a create and name a sheet:
which is great, works fine. Except when I need to use the name in a Formula:
This doesn't work. Does anyone know how I can get the formula to select the right sheet?
Any help would be much appreciated.
I've created a simple For Loop thingy and one of the things it does is name a create and name a sheet:
Code:
Dim WB As Workbook
Set WB = Workbooks("Workbook")
Dim List As Worksheet
Set List = WB.Sheets("Sheet1")
Dim r As Integer
Dim Last_Row As Integer
Last_Row = Application.WorksheetFunction.CountA(List.Range("A:A"))
'Start Loop
For r = 2 To Last_Row
WB.Sheets.Add
WB.ActiveSheet.Name = List.Range("A" & r).Value & "AE"
Dim AES As Worksheet
Set AES = WB.Sheets(List.Range("A" & r).Value & "AE")
which is great, works fine. Except when I need to use the name in a Formula:
Code:
Range("Q2:Q" & Range("A2").End(xlDown).Row).Formula = "=IF(COUNTIF('AE'!C:C,SUBSTITUTE((C2&D2),"" "",""""))=1,SUBSTITUTE((C2&D2),"" "",""""),"""")"
This doesn't work. Does anyone know how I can get the formula to select the right sheet?
Any help would be much appreciated.
Last edited by a moderator: