Here are two workarounds for the first sub.
#1 - Looping through range and array
'declare Worksheet variable to hold the exact sheet - ActiveSheet
is a quite random value
Dim ws As Worksheet
' declare and fill array
Dim xArrName As Variant
xArrName = Array("textBox25", "textBox4", "textBox6", "textBox8", "textBox19", "textBox9", "textBox10", "textBox11", "textBox22", "textBox12", "textBox23", "textBox5", "textBox7", "textBox24", "textBox1", "textBox3", "textBox14", "textBox8", "textBox19", "textBox9", "textBox10", "textBox11", "textBox22", "textBox12", "textBox23")
' declare a range to search values in
Dim workRange As Range
' assign a specific sheet to variable, you may need to change the sheet name
Set ws = ThisWorkbook.Sheets("Sheet1")
' declare iteration variable for columns - it's a good practice to
' grant variables with explanatory names
Dim columnIterator As Integer
'same for array iterator
Dim arrayIterator As Integer
' in case you want to loop through both array and range
' looping through range
For columnIterator = 14 To 1 Step -1
' looping through array
For arrayIterator = LBound(xArrName) To UBound(xArrName)
If ws.Cells(1, columnIterator).Value = xArrName(arrayIterator) Then
ws.Cells(1, columnIterator).EntireColumn.Delete
End If
Next
Next
' do other stuff
#2 - Using the '.Find()' method
'declare Worksheet variable to hold the exact sheet - ActiveSheet is a quite random value
Dim ws As Worksheet
' declare and fill array
Dim xArrName As Variant
xArrName = Array("textBox25", "textBox4", "textBox6", "textBox8", "textBox19", "textBox9", "textBox10", "textBox11", "textBox22", "textBox12", "textBox23", "textBox5", "textBox7", "textBox24", "textBox1", "textBox3", "textBox14", "textBox8", "textBox19", "textBox9", "textBox10", "textBox11", "textBox22", "textBox12", "textBox23")
' declare a range to search values in
Dim workRange As Range
' assign a specific sheet to variable, you may need to change the sheet name
Set ws = ThisWorkbook.Sheets("Sheet1")
' assign a range with binding to specific sheet
Set workRange = Range(ws.Cells(1, 1), ws.Cells(1, 14))
' that's just for looping through array
' like Nick.McDermaid suggestet
For arrayIterator = LBound(xArrName) To UBound(xArrName)
' in this case I DO know that if there
' will be no matches on .Find() function
' I will get an
' Run-time error '91': Object variable or With block variable not set
' error and can live with that for now
' so I use On Error Resume Next statement to ignore it
On Error Resume Next
workRange.Find(xArrName(arrayIterator)).EntireColumn.Delete
Next
' reset error handler after the loop
Err.Clear
' do other stuff
These approaches will work fine in case you dont have any values after the 'N' column (O, P, Q, R... etc), otherwise, those values will shift left and range "A1:N1" may contain deleted values again.
And this is for second sub, try using specific sheet and cells on it to set values
Sub change_header_2()
'declare Worksheet variable to hold the exact sheet - ActiveSheet is a
quite random value
Dim ws As Worksheet
' assign a specific sheet to variable, you may need to change the sheet name
Set ws = ThisWorkbook.Sheets("Sheet1")
' this construction will add values
' to specific cells on a specific sheet
With ws
.Cells(1, "A").Value = "Shift"
.Cells(1, "B").Value = "Clock In Time"
.Cells(1, "C").Value = "First Task"
.Cells(1, "D").Value = "Last Task"
.Cells(1, "E").Value = "Clock Out"
.Cells(1, "F").Value = "User"
.Cells(1, "G").Value = "Name"
End With
End Sub
And finally you should pay attention to Pᴇʜ's comment regarding variables declaration.