I currently have a function (which I am automating into a macro) =COUNTIF(export!$A$1:$CD$250000,"*Cycle*")
It scans a sheet and returns how many times the word cycle has been written.
My sheet name is "export" but this is constantly changing for each spreadsheet so I want to be able to pass the name of the Excel sheet into the formula automatically like so
=COUNTIF(Sheet name put here automatically!$A$1:$CD$250000,"*Cycle*")
Thank you for any replies
Edit: Full Macro
Sub Running_Mode()
'
' Running_Mode Macro
'
'
ActiveCell.FormulaR1C1 = "Cycle-Sentry"
Range("A2").Select
ActiveCell.FormulaR1C1 = "Continuous"
Range("A3").Select
ActiveCell.FormulaR1C1 = "Standby"
Range("B1").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(export!R1C1:R250000C82,""*Continuous*"")"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B2"), Type:=xlFillDefault
Range("B1:B2").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(export!R1C1:R250000C82,""*Cycle-Sentry*"")"
Range("B3").Select
ActiveCell.FormulaR1C1 = ""
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B3"), Type:=xlFillDefault
Range("B2:B3").Select
Range("B3").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(export!R1C1:R250000C82,""*Standby*"")"
Range("A1:B3").Select
Range("B3").Activate
ActiveSheet.Shapes.AddChart2(251, xlPie).Select
ActiveChart.ChartTitle.Select
ActiveChart.ChartTitle.Text = "Running Modes"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Running Modes"
With Selection.Format.TextFrame2.TextRange.Characters(1, 13).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 13).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With
ActiveChart.ChartArea.Select
End Sub```