"Compile error: Sub or Function not defined" Not sure how to fix

Figritout

New Member
Joined
Dec 4, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Sub EditFile()
' Unhide Row 1
Rows("1:1").Hidden = False

' Expand Column B to a width of 29.00
Columns("B:B").ColumnWidth = 29

' Unfreeze Panels
ActiveWindow.FreezePanes = False

' Delete Rows 1 through 8
Rows("1:8").Delete

' Delete Column A
Column("A:A").Delete

' Delete Columns C, D, E
Columns("C:E").Delete

' Delete Columns G, H, I, J, K, L, M
Columns("G:M").Delete
End Sub


Is what I have entered and it is to auto edit a file for me after I add it to a workbook. I only want one of the sheets edited and This is the error I keep getting.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Welcome to the Board!

This line:
VBA Code:
Column("A:A").Delete

should be this:
VBA Code:
Columns("A:A").Delete

Note: If you try compiling the code, it shows the error and takes you right to the offending line!
 
Upvote 0
Solution
Thank you!! I'll correct this, but it specifically pointed out the "Sub EditFile()" line as well. Would this need to change too?
 
Upvote 0
Thank you!! I'll correct this, but it specifically pointed out the "Sub EditFile()" line as well. Would this need to change too?
Try making the fix I suggested and see if you still have any issues.
If you do, I suspect it will be a different error message.
 
Upvote 0
Thank you so much, that was the fix I needed! This is my first time doing anything like this so I appreciate the assist. Next on the list is creating a button to automate adding formulas with a new sheet sheet name as they are added to my workbook.
 
Upvote 0
Thank you so much, that was the fix I needed! This is my first time doing anything like this so I appreciate the assist. Next on the list is creating a button to automate adding formulas with a new sheet sheet name as they are added to my workbook.
Excellent! Glad I was able to help!

You can post your new question to a new thread. It is best to do that so that it appears as a new unanswered question on the "Unanswered threads" list that many people use to look for unanswered questions to respond to.
 
Upvote 0

Forum statistics

Threads
1,225,635
Messages
6,186,125
Members
453,340
Latest member
Stu61

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top