Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Compile error:

Compile error:

Expected Function or variable

I am getting this error when, after selecting a cell, I use
selection.copy

this had been working, and then all of a sudden today it started giving me
an error
HELP!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Compile error:

There is nothing on that line that should cause a compile error. When you say
compile I assume you mean Debug - Compile... Off the top of my head I would
look for a missing reference Tools - References - Missing: ??? If that is
not it post the rest of your code.
--
HTH...

Jim Thomlinson


"jweasl" wrote:

Compile error:

Expected Function or variable

I am getting this error when, after selecting a cell, I use
selection.copy

this had been working, and then all of a sudden today it started giving me
an error
HELP!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default here's the whole code

Sub FabGutterCutLength_bid()
'
' FabGutterCutLength_bid Macro
' Macro recorded 12/8/2005 by Jeremy
'

'
Application.ScreenUpdating = False
Range("B12").Select
selection.Copy
Sheets("Quote Worksheet").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(44, 9).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 1).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(17, 1).Range("A1").Select
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(-17, 0).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 8).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, -10).Range("A1").Select
Sheets("Fab Gutters").Select
Range("B6").Select
Application.ScreenUpdating = True
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default here's the whole code

That compiles for me... I assume you do not have a problem with references? I
assume that this is a compile issue and not a runtime issue?
--
HTH...

Jim Thomlinson


"jweasl" wrote:

Sub FabGutterCutLength_bid()
'
' FabGutterCutLength_bid Macro
' Macro recorded 12/8/2005 by Jeremy
'

'
Application.ScreenUpdating = False
Range("B12").Select
selection.Copy
Sheets("Quote Worksheet").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(44, 9).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 1).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(17, 1).Range("A1").Select
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(-17, 0).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 8).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, -10).Range("A1").Select
Sheets("Fab Gutters").Select
Range("B6").Select
Application.ScreenUpdating = True
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default here's the whole code

It only gives me the error when I run it. It doesn't give me any errors until
I run the macro, then I get the

Compile error:

Expected Function or variable

and it highlights "selection.Copy" as being the problem

"Jim Thomlinson" wrote:

That compiles for me... I assume you do not have a problem with references? I
assume that this is a compile issue and not a runtime issue?
--
HTH...

Jim Thomlinson


"jweasl" wrote:

Sub FabGutterCutLength_bid()
'
' FabGutterCutLength_bid Macro
' Macro recorded 12/8/2005 by Jeremy
'

'
Application.ScreenUpdating = False
Range("B12").Select
selection.Copy
Sheets("Quote Worksheet").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(44, 9).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 1).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(17, 1).Range("A1").Select
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(-17, 0).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 8).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, -10).Range("A1").Select
Sheets("Fab Gutters").Select
Range("B6").Select
Application.ScreenUpdating = True
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default here's the whole code

and I don't know anything about references :-(

"Jim Thomlinson" wrote:

That compiles for me... I assume you do not have a problem with references? I
assume that this is a compile issue and not a runtime issue?
--
HTH...

Jim Thomlinson


"jweasl" wrote:

Sub FabGutterCutLength_bid()
'
' FabGutterCutLength_bid Macro
' Macro recorded 12/8/2005 by Jeremy
'

'
Application.ScreenUpdating = False
Range("B12").Select
selection.Copy
Sheets("Quote Worksheet").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(44, 9).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 1).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(17, 1).Range("A1").Select
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(-17, 0).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 8).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, -10).Range("A1").Select
Sheets("Fab Gutters").Select
Range("B6").Select
Application.ScreenUpdating = True
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default here's the whole code

Selection is usually capitalized by the VBE (not selection (with the lower case
s)).

Is there a chance you used "selection" as a variable name somewhere in your
code? Maybe as a public variable in one of the other modules????



jweasl wrote:

and I don't know anything about references :-(

"Jim Thomlinson" wrote:

That compiles for me... I assume you do not have a problem with references? I
assume that this is a compile issue and not a runtime issue?
--
HTH...

Jim Thomlinson


"jweasl" wrote:

Sub FabGutterCutLength_bid()
'
' FabGutterCutLength_bid Macro
' Macro recorded 12/8/2005 by Jeremy
'

'
Application.ScreenUpdating = False
Range("B12").Select
selection.Copy
Sheets("Quote Worksheet").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(44, 9).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 1).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(17, 1).Range("A1").Select
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(-17, 0).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 8).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, -10).Range("A1").Select
Sheets("Fab Gutters").Select
Range("B6").Select
Application.ScreenUpdating = True
End Sub


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default here's the whole code

aaaaaaaaahhhhhhh

i'm an idiot. while doing a little testing earlier today (hence the problem
TODAY), i recorded a macro in that workbook with the name selection. Thanks
for your help & time, I'll try not to be so stupid next time :-P

"Dave Peterson" wrote:

Selection is usually capitalized by the VBE (not selection (with the lower case
s)).

Is there a chance you used "selection" as a variable name somewhere in your
code? Maybe as a public variable in one of the other modules????



jweasl wrote:

and I don't know anything about references :-(

"Jim Thomlinson" wrote:

That compiles for me... I assume you do not have a problem with references? I
assume that this is a compile issue and not a runtime issue?
--
HTH...

Jim Thomlinson


"jweasl" wrote:

Sub FabGutterCutLength_bid()
'
' FabGutterCutLength_bid Macro
' Macro recorded 12/8/2005 by Jeremy
'

'
Application.ScreenUpdating = False
Range("B12").Select
selection.Copy
Sheets("Quote Worksheet").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(44, 9).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 1).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(17, 1).Range("A1").Select
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(-17, 0).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 8).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, -10).Range("A1").Select
Sheets("Fab Gutters").Select
Range("B6").Select
Application.ScreenUpdating = True
End Sub


--

Dave Peterson

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default here's the whole code

Selects can be a problem... Same with refences to the active cell. They can
be cleaned up to make the code faster and less prone to failure. Try
something more like this...

Sub FabSheetsBid()
Dim wksFabGutters As Worksheet
Dim wksQuote As Worksheet

Set wksFabGutters = Sheets("Fab Gutters")
Set wksQuote = Sheets("Quote Worksheet")

wksFabGutters.Range("A1").Copy
wksQuote.Range("A1").PasteSpecial xlPasteValues
wksFabGutters.Range("A100").Copy
wksQuote.Range("A10").PasteSpecial xlPasteValues
Application.CutCopyMode = False

end sub
--
HTH...

Jim Thomlinson


"jweasl" wrote:

It only gives me the error when I run it. It doesn't give me any errors until
I run the macro, then I get the

Compile error:

Expected Function or variable

and it highlights "selection.Copy" as being the problem

"Jim Thomlinson" wrote:

That compiles for me... I assume you do not have a problem with references? I
assume that this is a compile issue and not a runtime issue?
--
HTH...

Jim Thomlinson


"jweasl" wrote:

Sub FabGutterCutLength_bid()
'
' FabGutterCutLength_bid Macro
' Macro recorded 12/8/2005 by Jeremy
'

'
Application.ScreenUpdating = False
Range("B12").Select
selection.Copy
Sheets("Quote Worksheet").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(44, 9).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 1).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(17, 1).Range("A1").Select
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(-17, 0).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 8).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, -10).Range("A1").Select
Sheets("Fab Gutters").Select
Range("B6").Select
Application.ScreenUpdating = True
End Sub

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default here's the whole code

Just be glad you didn't capitalize that macro's name!

jweasl wrote:

aaaaaaaaahhhhhhh

i'm an idiot. while doing a little testing earlier today (hence the problem
TODAY), i recorded a macro in that workbook with the name selection. Thanks
for your help & time, I'll try not to be so stupid next time :-P

"Dave Peterson" wrote:

Selection is usually capitalized by the VBE (not selection (with the lower case
s)).

Is there a chance you used "selection" as a variable name somewhere in your
code? Maybe as a public variable in one of the other modules????



jweasl wrote:

and I don't know anything about references :-(

"Jim Thomlinson" wrote:

That compiles for me... I assume you do not have a problem with references? I
assume that this is a compile issue and not a runtime issue?
--
HTH...

Jim Thomlinson


"jweasl" wrote:

Sub FabGutterCutLength_bid()
'
' FabGutterCutLength_bid Macro
' Macro recorded 12/8/2005 by Jeremy
'

'
Application.ScreenUpdating = False
Range("B12").Select
selection.Copy
Sheets("Quote Worksheet").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(44, 9).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 1).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(17, 1).Range("A1").Select
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(-17, 0).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Fab Gutters").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Application.CutCopyMode = False
selection.Copy
Sheets("Quote Worksheet").Select
ActiveCell.Offset(0, 8).Range("A1").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, -10).Range("A1").Select
Sheets("Fab Gutters").Select
Range("B6").Select
Application.ScreenUpdating = True
End Sub


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
error message: compile error, argument not optional Pierre via OfficeKB.com Excel Programming 3 September 5th 05 03:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM
Compile error in hidden module error Melissa Zebrowski Excel Programming 3 February 20th 04 01:29 PM


All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"