Shell Function Compile Error - Expected Procedure Not Variable

Aug 8, 2014

I have a VBA shell script that worked just fine on another computer, but now it won't run.

The code that won't execute is:

[Code] ........

View 12 Replies


ADVERTISEMENT

Compile Error Expected Function Or Variable

Jul 27, 2006

Need the right direction to stop the error 'Compile Error Expected Function or Variable' appearing. I have both of the following codes in a module. The AddNewTenancy works perfectly but the EditTenancy comes up with the following error.
Both the Userforms exist so I know it's not that.

Sub EditTenancy()
EditTenancy.Show
End Sub
Sub AddNewTenancy()
NewTenancy.Show
End Sub

View 2 Replies View Related

Copy And Paste Special Values But Getting Error 'Compile Error - Expected Function Or Variable'

Feb 7, 2007

I am trying to run create a simple macro that copies and paste special values - something I have done 100's of times but for some reason I keep getting an error message - even though I recorded the macro and didnt write it by hand - see below:

Sub Macro6()
Cells.Select
selection.Copy
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

For which I get 'Compile Error - Expected Function or Variable'

View 6 Replies View Related

Compile Error: = Expected After Function Call

Dec 18, 2006

i'm trying to call a function from another one, i'm getting this error 'Compiler error: = expected' but i don't know the reason, the functions simply take some values an store them in an here is the

Dim productos(19, 3) As String
Sub agregarProducto(ByVal descripcion As String, ByVal modelo As String, _
ByVal precio As String, ByVal unidad As String)
Dim r As Integer
For r = 0 To 19
If productos(r, 0) = "" Then
productos(r, 0) = descripcion
productos(r, 1) = modelo
productos(r, 2) = precio
productos(r, 3) = unidad
End If
Next
End Sub

Sub agregarProductoTelas()
Dim descripcion, modelo, precio, unidad As String
If Selection.Column = 1 Then
descripcion = Selection. Offset(0, 0).Value
modelo = Selection.Offset(0, 0).Value
precio = Selection.Offset(0, 3).Value
unidad = Selection.Offset(0, 2).Value
agregarProducto(descripcion, modelo, precio, unidad) 'error happens right here
MsgBox (descripcion)...

View 3 Replies View Related

Compile Error Expected Line Number - End Statement

Apr 18, 2014

I am getting this error and where th If not starts its is in red showing that is where the issue is:

HTML Code: 

Sub RemoveRows()
Dim LR As Long, i As Long
Dim ws As Worksheet
Set ws = Worksheets("100 Airports")
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = LR To 10 Step -1

[Code] .....

View 3 Replies View Related

Clear Contents Macro For Merge Cell (Compile Error - Expected End Sub)

Jun 13, 2014

I'm trying to use the "clear contents macro" for merge cell, but I keep receiving this "compile error : Expected End Sub" error.

FYI, I have named my merge cells to "myMergedCells"

[Code] .....

View 3 Replies View Related

Error Message (Compile Error, Procedure Too Large)

May 20, 2009

I am looking for a more efficient way to write a macro (a sample from the macro is below). This is just the first part of the macro. I need to repeat these same steps (seen for row 5 below) for rows 5 to 50. My script worked until I hit row 35 and then I got the "compile error.." message. There must be a way to use "loop" to write this more efficiently, no?

View 14 Replies View Related

Compile Error / Invalid Outside Procedure

Nov 21, 2011

Compile Error: Invalid Outsid Procedure

I have Compile error coming up when I try to run Sub DeleteRecord on Sheet 2. It brings me to the VBE with sheet 1 code brought up and the Compile Error showing, with the xlup portion of the code highlighted. I okay the error and it highlights the Sub DeleteRecord on Sheet 2 with a yellow arrow.

Sheet 1 code as follows:

Dim y As Long
y = Range("A65536").End(xlUp).Row
Range("A1").AutoFill Destination:=Range("A1:A" & y), Type:=xlFillDefault
Range("J1").AutoFill Destination:=Range("J1:J" & y), Type:=xlFillDefault
Range("K1").AutoFill Destination:=Range("K1:K" & y), Type:=xlFillDefault
Range("L1").AutoFill Destination:=Range("L1:L" & y), Type:=xlFillDefault
Range("M1").AutoFill Destination:=Range("M1:M" & y), Type:=xlFillDefault
Range("N1").AutoFill Destination:=Range("N1:N" & y), Type:=xlFillDefault
Range("O1").AutoFill Destination:=Range("O1:O" & y), Type:=xlFillDefault
Range("P1").AutoFill Destination:=Range("P1:P" & y), Type:=xlFillDefault

Sheet 2 code at follows:

Sub DeleteRecord()
'
' DeleteRecord Macro
'
'
Application.ScreenUpdating = False
ActiveSheet.Unprotect
ActiveCell.Offset(4, 3).Range("A1:H2").Select

[code]....

View 3 Replies View Related

Compile Error: Procedure Too Large

Jun 18, 2008

I am new to visual basic editor and I have a new position which right now has me copying and pasting a macro to hide all rows that contain zeros. I have attached a piece of it. There are 1,024 rows total and I got to row 479 and I get the error message.

It is telling me to "break up" the procedure, but I have no idea what that means or how to do it. There has got to be an easier way to do this.

Sub HideZeroCells()
If Range("g18") = "0" Then
Rows("18:18").Select
Selection.EntireRow.Hidden = True
End If
''
If Range("g22") = "0" Then
Rows("22:22").Select
Selection.EntireRow.Hidden = True
End If
''
If Range("g23") = "0" Then
Rows("23:23").Select.......................

View 9 Replies View Related

Compile Error Procedure Too Large When Trying To Run Macro

May 29, 2013

I am running into a Procedure too large error when running my macro. My macro is designed to replace a cell value with another cell value in a list. When the cell value is replaced a vlookup brings in new data to my workboook. Then the macro refreshes all the pivot tables and saves the workbork. I want my macro to repeat the above 60 times, so I have copied the code 60 times and changed the ActiveCell.FormulaR1C1 to point to the next value in my list. (Is there another way to select the next value from the list without changing the Row and Column number?) This is where my macro fails.

Below is my code.

VB:
Sheets("Data").Select
Range("B2").Select
[COLOR=#FF0000] ActiveCell.FormulaR1C1 = "=RC[25]" ' AGC GRP_ID[/COLOR]
Sheets("Ship pivot and cum triangle").Select
ActiveSheet.PivotTables("PivotTable4").RefreshTable
Application.DisplayAlerts = False

[Code] .....

View 9 Replies View Related

Compile Error: Invalid Outside Procedure (making Changes To Row)

Jan 16, 2009

I'm making changes to row A, but am getting an invalid outside procedure, not sure why. Don't even know what it means. It's not even in the same worksheet....

View 9 Replies View Related

Expand Cell Width - Compile Error Procedure Too Large

Aug 8, 2012

The following code expands a cell width to size 42 when it is clicked on, then minimises it to size 9.29 when clicked elsewhere. Just what I need.

For instance, this would work for column 4.

VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Columns(4).ColumnWidth = IIf(Target.Column = 4, 42, 9.29)
End Sub

However, I need this to cover the first 1000 columns. More if possible. I can easily copy this 1000 times, changing the column number to then look like this (First 10 shown for example)

VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Columns(4).ColumnWidth = IIf(Target.Column = 4, 42, 9.29)
Columns(5).ColumnWidth = IIf(Target.Column = 5, 42, 9.29)
Columns(6).ColumnWidth = IIf(Target.Column = 6, 42, 9.29)

[Code] .....

The problem is if I do this 1000 times i get a Compile error that the procedure is too large. Is it possible to make the code more compact to basically cover all columns from 4 onward?

View 6 Replies View Related

Compile Error: Invalid Outside Procedure (execute Macro On Pivot Refresh)

Jan 27, 2009

I keep getting this error:

"Compile Error: Invalid outside procedure"

What I am doing is having a macro execute every time my Pivot table is refreshed, the macro invokes a format change.

View 3 Replies View Related

VBA - Use A Variable To Name My Object - Getting Compile Error?

Mar 19, 2013

I have an application that will require I create 20+ objects from a class I have created call "cWorkCenter." This is my first project using objects in VBA. I've created a string variable called "Title." THe application will loop through a list of resources on a worksheet, assign the name of that resource to the variable called "Title" (eg. Title=Range("A1")), then create an object named whatever the string is that "Title" represents. For example, if the first item in my list is "Resource1", then the first object created should be called "Resource1"

When I do this I get the following error: Compile Error: Duplicate declaration in current scope.

Below is the part of the code giving me trouble.

VB:
Public Title As String
Sub Loader_OO()
Title = "Resource1" [code].....

View 2 Replies View Related

Compile Error - Variable Not Defined

Aug 12, 2014

New to VBA and just trying to make some edits to some existing code. I have basically copied a pre-existing form and module and changed names from "Appendix" to "Drawing" as I am trying to replicate what the piece of code already produces for a table of appendices, for my drawings.

However, when I try and run the form I get Compile error: Variable not defined with lstDrawings highlighted.

[Code] ...........

Is this something that should be defined in my global module which I am missing?

View 3 Replies View Related

Compile Error - Variable Not Defined

Jan 21, 2012

The following code has been used previously to enter data from a userform to a worksheet without a problem. However, since I added some new bits of code I am getting a compile error with the message variable not defined.

Here is part of what I have so far and the bit that is highlighted after the error comes up is the 'Set ws' line;

Code:
Private Sub CommandButton1_Click()
Worksheets("Duties").Range("C5") = txtdate
Worksheets("Duties").Range("H5") = txtarea
Worksheets("Duties").Range("N5") = txttea
Set ws = Worksheets("Duties")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

The code I have recently added:

Code:
Private Sub UserForm_Initialize()
Set wsRes = Worksheets("Resources")
With wsRes
.Range("B1", .Range("B" & Rows.Count).End(xlUp)).AdvancedFilter xlFilterCopy, , .Range("L1"), True
With .Range("L2", .Range("L" & Rows.Count).End(xlUp))
cboTeam.List = .Value
.EntireColumn.Clear

[Code] .......

View 8 Replies View Related

VBA With Compile Error: Variable Not Defined

May 27, 2008

I've used Excel for many years, but finally am learning VBA, using Excel Progamming for Dummies by John Walkenbach. Excel is version 2000.

I've searched extensively on Google and on the MrExcel site for the solution to my problem, but still haven't found it . Any direction would be most appreciated.

I'm trying to execute the examples in the book, and have gotten the error message "Compile error: Variable not defined" with "MyString =" highlighted with several of the examples. Could someone please tell me where I'm going astray?

Following is the latest subroutine I typed into the module, from page 124:

Option Explicit

Sub GetLength()
MyString = "Hello World"
StringLength = Len(MyString)
MsgBox StringLength
End Sub

View 9 Replies View Related

Compile Error - Variable Not Defined

May 6, 2009

I keep getting 'compile error - variable not defined' in the following

Sub LockIt()
TextBox1 = ""
End Sub

View 9 Replies View Related

Getting A Compile Error Variable Not Defined

Jan 13, 2010

It works as a regular Module but when I put it into a "Private Sub" for a button its not working.

Basically I have a master sheet that I create Tests from. I push a button and it creates a Test for others to take. I want the macro to transfer from the Master to these so when they are done I can press a button and upload the answers to a tracking sheet.

It errors on the strSecondFile

Private Sub CommandButton1_Click()
Dim wbk As Workbook
Dim NAME As String

'strFirstFile = ActiveWorkbook
strSecondFile = Application.GetOpenFilename
Set wbk = ActiveWorkbook 'Workbooks.Open(strFirstFile)
NAME = Range("A6").Value

View 9 Replies View Related

Compile Error: Variable Not Defined

Jul 18, 2006

I came across a weird situation using a standard print macro. One of my users could not use the print macro due to a compile error. The row that was highlighted was

.PrintErrors = xlPrintErrorsDisplayed

the error states that the variable is not defined. I removed that line of code and everything prints fine.

I tested this code out on excel 97 and it worked; is this sensitive to OS version? Will leaving this line of code effect anything big?

View 9 Replies View Related

Compile Error / Invalid Next Control Variable Reference

Jul 16, 2013

I have written the following VBA Script but am getting an error message saying -> "Compile Error. Invalid Next control variable reference".

Code:

Sub Form1() 'Change Yes/No
Dim bottomT1 As Integer
bottomT1 = Sheets("Data Sheet").Range("T" & Rows.Count).End(xlUp).Row
Dim bottomP2 As Integer
bottomP2 = Sheets("Follow-Up").Range("P" & Rows.Count).End(xlUp).Row
Dim bottomO2 As Integer
bottomO2 = Sheets("Follow-Up").Range("O" & Rows.Count).End(xlUp).Row

[code].....

View 5 Replies View Related

Compile Error - Variable Not Defined Involving Multiple If Statements

Jan 27, 2014

I am trying to put two subs into a macro. They work individually, but when I put them together, I get a "Compile Error: Variable Not Defined" Message. I was told I have to define the variable in the sub multipleif(), but I am not certain as to how to do this. The error message highlights the line I have bolded below.

VB:
Option Explicit
Private Sub CommandButton1_Click()
Dim mth As Variant, txt As Variant, des As Variant, wdt As Variant, I, Cell

[Code]....

View 5 Replies View Related

Compile Error: Invalid Use Of Object: Releasing Variable From Memory

Oct 19, 2006

I'm having trouble releasing a String variable from Memory...

View 9 Replies View Related

Get Compile Error - Sub Or Function Not Defined?

Apr 9, 2014

Trring to use function edate() in VBA macro, I've activated atpvbaen.xls in Tools/Register but get compile error:"Sub or function not defined".

View 5 Replies View Related

Compile Error / Sub Or Function Not Defined

Jul 9, 2014

Have two worksheets in same workbook. First worksheet is "ReArrangedAddr" Which basically has a command button to click to run a "Sub" behind the second worksheet "Orig SH Register". When I click on button on first worksheet, I get error "Compile Error: Sub or Function not defined"

* * * * * code behind command button * * * * *

View 14 Replies View Related

Compile Error With Find Function

Mar 31, 2009

I am trying to use the Find function within some VBA code but keep encountering a compile error. Code works fine on it's own as below but doesn't work within the VBA code. I can't figure out what part of code needs to be modified.

The desired result in J2 = "Jim"

the value in cell I2 = "Jim |Anderson"

Working Function as follows:

View 3 Replies View Related

Compile Error / Sub Or Function Not Defined

May 17, 2012

I have a two set of Macros in a workbook. One is to create a command button on a sheet and other macro will run onece the created commond button is clicked.

Macro runs fine. Command button gets created, but when I click the command button to run another macro it gives error "Compile Error: Sub or Function not defined" highlighting the code "Call Add" at the code entered for sheet. This code is added by macro in the sheet1. I am attaching a sample file as well as codes.

Sub CreateButton()
Dim Obj As Object
Dim Code As String
Sheets("Sheet1").Select
'create button
Set Obj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
Link:=False, DisplayAsIcon:=False, Left:=600, Top:=30, Width:=100, Height:=35)
Obj.Name = "InsertInvoiceButton"
'buttonn text

[code]....

View 9 Replies View Related

Compile Error - Only Comments May Appear After Sub End Function

Aug 13, 2013

Why do I get the below error when I open my workbook? The highlighted function is below.

Private Sub CommandButton1_Click()
Dim myText As Variant
If TextBox1.Value = "code" Then
UserForm1.Hide
Else
Me.Label1.Visible = True
Me.Label1.ForeColor = vbRed
End If
End Sub

View 1 Replies View Related

Compile Error: Sub Or Function Not Defined

Jul 28, 2006

Can someone explain the concept of defining the "Sub" to me.

View 5 Replies View Related

Defined Function - Compile Error Block If Without End If

Mar 17, 2014

I have created the following defined function in excel VBA but i get the complie error:-

'Block if without end if'

This this the code I have written for the function:-

Public Function Rule_45(Current, Previous, Result)
' RED: 'Decreasing Trend' OR 'Same' AMBER:'Increasing Trend' GREEN:'>83%'
If Result = "-" Then
Rule_45 = "-"

[Code].....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved