pavlusha15 Пользователь Сообщений: 4 |
#1 25.06.2017 22:09:12 Дело в том, что на одном листе создана кнопка и к нему привязан модуль с макросом, я хочу переместить кнопку в форму, но вылазит ошибка «Expected End Sub»
Изменено: pavlusha15 — 25.06.2017 22:44:48 |
||
Hugo Пользователь Сообщений: 23134 |
Где-то в форме недописано окончание макроса. |
pavlusha15 Пользователь Сообщений: 4 |
#3 25.06.2017 22:20:28
Хм, ну где именно? |
||
pavlusha15 Пользователь Сообщений: 4 |
#4 25.06.2017 22:21:23
Когда поставил в кнопку, вот так Изменено: pavlusha15 — 25.06.2017 22:21:41 |
||
Ігор Гончаренко Пользователь Сообщений: 13262 |
#5 25.06.2017 22:23:30 а так:
или
как Вам удобно Изменено: Ігор Гончаренко — 25.06.2017 22:24:03 Программисты — это люди, решающие проблемы, о существовании которых Вы не подозревали, методами, которых Вы не понимаете! |
||||
Hugo Пользователь Сообщений: 23134 |
#6 25.06.2017 22:33:32
— хотелось ответить, но так отвечать нельзя
|
||||
pavlusha15 Пользователь Сообщений: 4 |
Я просто новичок в этом, спасибо вам большое! |
Юрий М Модератор Сообщений: 60389 Контакты см. в профиле |
pavlusha15, название темы у Вас никудышное. Предложите новое — модераторы поменяют. |
JayBhagavan Пользователь Сообщений: 11833 ПОЛ: МУЖСКОЙ | Win10x64, MSO2019x64 |
Юрий М, может так сгодится: <#0> |
Юрий М Модератор Сообщений: 60389 Контакты см. в профиле |
|
Ігор Гончаренко Пользователь Сообщений: 13262 |
#11 25.06.2017 22:58:00 в каком-то из модулей количество Sub больше, чем количество End Sub Программисты — это люди, решающие проблемы, о существовании которых Вы не подозревали, методами, которых Вы не понимаете! |
Содержание
- Thread: Compile Error: Expected End Sub
- Compile Error: Expected End Sub
- Re: Compile Error: Expected End Sub
- Re: Compile Error: Expected End Sub
- Re: Compile Error: Expected End Sub
- Re: Compile Error: Expected End Sub
- Re: Compile Error: Expected End Sub
- Re: Compile Error: Expected End Sub
- Microsoft Visual Basic Compile Error: Expected End Sub
- Microsoft Visual Basic Compile Error: Expected End Sub
- Re: Microsoft Visual Basic Compile Error: Expected End Sub
- Re: Microsoft Visual Basic Compile Error: Expected End Sub
- Re: Microsoft Visual Basic Compile Error: Expected End Sub
- Thread: [RESOLVED] Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
- [RESOLVED] Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
- Re: Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
- Re: Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
- Re: Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
- Re: Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
- VBA Compile Error
- Undeclared Variables
- Undeclared Procedures
- Incorrect Coding – Expected End of Statement
- Missing References
- VBA Coding Made Easy
- VBA Code Examples Add-in
Thread: Compile Error: Expected End Sub
Thread Tools
Display
Compile Error: Expected End Sub
Hi there, this is my first post so apologies in advance for the n00b questions.
I have a client who is getting this error every time he gets a calendar invite. Im not too familiar with VBS so Im hoping somebody here can make light of this?
Re: Compile Error: Expected End Sub
You are missing a line of code
Re: Compile Error: Expected End Sub
Hi there, this is my first post so apologies in advance for the n00b questions.
I have a client who is getting this error every time he gets a calendar invite. Im not too familiar with VBS so Im hoping somebody here can make light of this?
I don’t see how a client can be getting that error. did it actually build with error? In other words you are saying that a client is running your program and getting that error when the error you are showing us would prevent the program from compilingbuilding. Therefore it seems impossible the client can be getting that error. It is a program development error.
Last edited by TysonLPrice; Oct 19th, 2017 at 11:44 AM .
Re: Compile Error: Expected End Sub
I know what you mean, but OP might not .. maybe you could elaborate
Re: Compile Error: Expected End Sub
It looks like it is an Outlook VBA macro embeded in the CalInvite. or in something that’s running on their machine. It’s not compiled code. Probably should move this thread to the Office Dev section.
Re: Compile Error: Expected End Sub
How can anything run with a compiler error? Is it something that compiles at run-time like some of the the early third generation languages?
Re: Compile Error: Expected End Sub
But it isn’t running. it’s throwing an error. VBA Macro code files aren’t compiled until they are executed, so it’s very easy to botch one up, save it and never know until it goes to be executed. the VBA interpreter loads it up, attempts to compile it to run it, and viola! an error happens.
That’s what is happening here. He’s got a botched piece of VBA code in an Outlook macro that runs when a calendar invite arrives. When one does, Outlook attempts to run the code, but can’t because it’s broken.
Источник
Microsoft Visual Basic Compile Error: Expected End Sub
LinkBack
Thread Tools
Rate This Thread
Display
Microsoft Visual Basic Compile Error: Expected End Sub
I am receiving Microsoft Visual Basic Compile Error: Expected End Sub on the code listed below. Can anyone please help me decipher what needs to be corrected?
Last edited by jeffreybrown; 08-23-2012 at 03:49 PM .
Re: Microsoft Visual Basic Compile Error: Expected End Sub
You should put code in code tags — see the Forum Rules.
However, your first 2 lines are:
and so Excel would expect an End Sub before your second line.
Hope this helps.
Re: Microsoft Visual Basic Compile Error: Expected End Sub
And put your posted code in tags before the Mods get both the three of us .
Your post does not comply with Rule 3 of our Forum RULES . Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
Re: Microsoft Visual Basic Compile Error: Expected End Sub
Thank you for pointing out that code needs to be tagged.
I am still able to save the workbook without having the required cells fulfilled. Is the code I posted just prompting a message box (which I am not getting) or does it actually restrict the user from saving?
Last edited by jeffreybrown; 08-23-2012 at 03:49 PM .
Источник
Thread: [RESOLVED] Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
Thread Tools
Display
[RESOLVED] Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
Please can someone tell me where i am making mistake? Visual basic is giving error , it is sayin » Compile Error : Expected End Sub «
I am new with this program. I searched on the internet. I am using Private Sub or function wrongly i think. I put end but it still saying «End Sub».
Private Sub Form_Load()
Dim i As Integer
Dim x(1 To 100) As Double
ir = 0
x(1) = 2: x(2) = 3: AERROR = 0.001
Public Function f(ByVal x As Double) As Double
fx(i — 2) = x(i — 2) ^ 2
fx(i — 1) = x(i — 1) ^ 2
End Function
End Sub
Public Sub Calculate_Click()
For i = 3 To 100
x(i) = x(i — 1) — ((fx(i — 1) * (x(i — 1) — x(i — 2))) / (fx(i — 1) — fx(i — 2)))
If Abs(x(i) — x(i — 1))
Re: Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
you’re trying to put a function inside of a sub. you can’t do that. also, your function as it is, doesn’t return anything. further complicating it, your function uses a variable array fx that’s undefined. the short of it, there’s a lot more than just a «missing» end sub here.
I’d try to fix it, but I don’t know what it’s doing, what it’s supposed to do or what fx() is supposed to be. so I’m not sure where to start.
Re: Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
I thought i defined my function by writing
» Public Function f(ByVal x As Double) As Double
fx(i — 2) = x(i — 2) ^ 2
fx(i — 1) = x(i — 1) ^ 2
End Function»
My first values are x1=2 and x2=3 and my function is Fx=x^2 (it is just example) and i am trying to find xn(the last value) by using sekant method (differention equation method). As As i state , formule is » x(i) = x(i — 1) — ((fx(i — 1) * (x(i — 1) — x(i — 2))) / (fx(i — 1) — fx(i — 2))) «
So When You put x1 and x2 ;you are finding x3 and by using x3 and x2 u can find x4.
My aim is to find xn .
Re: Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
I thought i defined my function by writing
» Public Function f(ByVal x As Double) As Double
fx(i — 2) = x(i — 2) ^ 2
fx(i — 1) = x(i — 1) ^ 2
End Function»
My first values are x1=2 and x2=3 and my function is Fx=x^2 (it is just example) and i am trying to find xn(the last value) by using sekant method (differention equation method). As As i state , formule is » x(i) = x(i — 1) — ((fx(i — 1) * (x(i — 1) — x(i — 2))) / (fx(i — 1) — fx(i — 2))) «
So When You put x1 and x2 ;you are finding x3 and by using x3 and x2 u can find x4.
My aim is to find xn .
Sorry i gave a wrong equation . i cant say x^2 ,because the roots are 0. So i am giving x^2-16. So it will find the root xn=4
Re: Visual basic’S error » Compile Error : Expected End Sub» and where it comes?
Right now i’m trying to understand what this function is supposed to do.
Math-classes were some 25 years ago.
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
———————————————————————————
People call me crazy because i’m jumping out of perfectly fine airplanes.
———————————————————————————
Code is like a joke: If you have to explain it, it’s bad
Источник
VBA Compile Error
In this Article
This tutorial will explain what a VBA Compile Error means and how it occurs.
Before running your code, the VBA Editor compiles the code. This basically means that VBA examines your code to make sure that all the requirements are there to run it correctly – it will check that all the variables are declared (if you use Option Explicit which you should!), check that all the procedures are declared, check the loops and if statements etc. By compiling the code, VBA helps to minimize any runtime errors occurring.
(See our Error Handling Guide for more information about VBA Errors)
Undeclared Variables
If you do not declare variables, but your Option Explicit is switched on at the top of your module, and then you run the macro, a compile error will occur.
If you click OK, the relevant procedure will go into debug mode.
Alternatively, before you run your code, you can force a compilation of the code.
In the Menu, select Debug > Compile Project.
The compiler will find any compile errors and highlight the first one it finds accordingly.
Undeclared Procedures
If you code refers to a procedure that does not exist, you will also get a compile error.
However, if the procedure – NextProcedure does not exist, then a compile error will occur.
Incorrect Coding – Expected End of Statement
If you create a loop using For..Each..Next or With..End With and forget to and the Next or the End With… you will also get a compile error.
The same will happen with an If statement if the End If is omitted!
Missing References
If you are using an Object Library that is not part of Excel, but you are using the objects from the library in your variable declaration, you will also receive a compile error.
This can be solved by either Late Binding – declaring the variables are Objects; or by adding the relevant Object Library to the Project.
In the Menu, select Tools > References and add the relevant object library to your project.
VBA Coding Made Easy
Stop searching for VBA code online. Learn more about AutoMacro — A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!
VBA Code Examples Add-in
Easily access all of the code examples found on our site.
Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.
Источник
megionkik 0 / 0 / 0 Регистрация: 07.05.2015 Сообщений: 3 |
||||
1 |
||||
06.02.2017, 09:10. Показов 11769. Ответов 7 Метки нет (Все метки)
Добрый день! В Vba — я ноль
__________________
0 |
Заблокирован |
|
06.02.2017, 09:14 |
2 |
Sub Macros1() — УБРАТЬ!
0 |
megionkik 0 / 0 / 0 Регистрация: 07.05.2015 Сообщений: 3 |
||||
06.02.2017, 09:33 [ТС] |
3 |
|||
Просит создать макрос, написал название и вот что вышло
Добавлено через 9 минут
0 |
2 / 2 / 0 Регистрация: 03.08.2015 Сообщений: 153 |
|
13.12.2017, 16:34 |
4 |
Подскажите, что компилятору не нравится? End Sub же есть! Миниатюры
0 |
2561 / 1584 / 724 Регистрация: 23.03.2015 Сообщений: 4,957 |
|
13.12.2017, 17:00 |
5 |
Rikozenit,
0 |
2 / 2 / 0 Регистрация: 03.08.2015 Сообщений: 153 |
|
13.12.2017, 17:04 |
6 |
Когда убираю последнюю — он также ругается, когда убираю и первую тоже — он её сам автоматически назад возвращает(
0 |
Заблокирован |
|
13.12.2017, 17:10 |
7 |
убирайте одновременно.
1 |
1783 / 1111 / 340 Регистрация: 11.07.2014 Сообщений: 3,926 |
|
14.12.2017, 09:54 |
8 |
Rikozenit, а ругается потому что описание функции находится внутри Sub, а не надо этого делать, вынесите из саба, а всабе поставьте обращение к этой функции A=F(…) А первый ваш макрос работает, только непонятно зачем надо накапливать комментарии? Ну это вам виднее. Добавлено через 10 минут
1 |
Sub PrepCallScheduleFiles()
'
' PrepCallScheduleFiles Macro
'
' Keyboard Shortcut: Ctrl+a
'Run macro across muliple workbook files at the same time without opening them.
'A browse window should be displayed to select folder which contains the CSV files to apply this macro
Sub LoopThroughFiles()
Dim xFd As FileDialog
Dim xFdItem As Variant
Dim xFileName As String
Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
If xFd.Show = -1 Then
xFdItem = xFd.SelectedItems(1) & Application.PathSeparator
xFileName = Dir(xFdItem & "*.xls*")
Do While xFileName <> ""
With Workbooks.Open(xFdItem & xFileName)
'Autofit columns, find & replace *_, hide columns & format for printing
Columns("A:U").EntireColumn.AutoFit
Columns("O:O").Select
Selection.Replace What:="_*", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Range("N1,A:A,G:G,K:K,L:L,M:M,N:N").Select
Selection.EntireColumn.Hidden = True
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = -3
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
Dim xFd As FileDialog
Dim xSPath As String
Dim xCSVFile As String
Dim xWsheet As String
Application.DisplayAlerts = False
Application.StatusBar = True
xWsheet = ActiveWorkbook.Name
Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
xFd.Title = "Select a folder:"
If xFd.Show = -1 Then
xSPath = xFd.SelectedItems(1)
Else
Exit Sub
End If
If Right(xSPath, 1) <> "" Then xSPath = xSPath + ""
xCSVFile = Dir(xSPath & "*.csv")
Do While xCSVFile <> ""
'Convert workbooks from CSV to XLSX
Application.StatusBar = "Converting: " & xCSVFile
Workbooks.Open Filename:=xSPath & xCSVFile
ActiveWorkbook.SaveAs Replace(xSPath & xCSVFile, ".csv", ".xlsx", vbTextCompare), xlWorkbookDefault
ActiveWorkbook.Close
Windows(xWsheet).Activate
xCSVFile = Dir
Loop
Application.StatusBar = False
Application.DisplayAlerts = True
End With
xFileName = Dir
Loop
End If
End Sub