Hello!
Starting Point: I have a master sheet, where I can activate a new sheet with a checkbox that gets the name of a certain cell. Afterwards I want to switch back to the master sheet and insert some formulas containing the name of the new sheet. The problem is I get a 2023 error for the variables that I marked red in the following code. I know it is a reference error but I dont know how to fix it. I just want the macro to insert the formula instead of checking reference. The code that the variable produces is correct (I tested it) and does what I want it to do, but the macro does not insert it:
Sub Diätplaner_Tagestyp_niedrig()
Dim VorgesehenAls As String
Dim EK As String
Dim KALORIEN As String
Dim Carbs As String
Dim Makroverhältnis As String
Dim Shtname As String
Shtname = Range("I73").Value
VorgesehenAls = "=IF(" & Shtname & "!E54=TRUE; ""TT"" ;""NTT"")"
EK = "=IF(" & Shtname & "!E54=TRUE;""TT"";""NTT"")"
KALORIEN = "=" & Shtname & "!49"
Carbs = "=" & Shtname & "!G49"
Makroverhältnis = "=TEXT(" & Shtname & "!F51*100;""0"")" & " / " & "TEXT(" & Shtname & "!G51*100;""0"")" & " / " & "TEXT(" & Shtname & "!H51*100;""0"")"
If Sheets("Diätplaner").Range("I72").Value = True Then
If WorksheetExistsNiedrig = False Then
Sheets("Diätplaner").Copy After:=ActiveSheet
ActiveSheet.Name = Shtname
Sheets("Diätplaner").Select
'Formeln einsetzen, die oben festgelegt wurden
Range("I75").Value = EK
Range("I76").Value = KALORIEN
Range("I78").Value = Makroverhältnis
Range("I79").Value = Carbs
Range("I74").Value = VorgesehenAls
Else
Exit Sub
End If
Else
[...]
End If
End Sub
Thanks a lot,
Taktiker
Bookmarks