473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Copying creates compiling error

Good morning,

I wrote some code today and it compiled fine in one xcel workbook. I copied it and set up the macro in a different workbook. Now it's giving me the following error:

Argument not optional

and pointing at my variable to determine the last row used in the tab. What did I do wrong? It's the SAME CODE!

Here is the entire code:

Sub UpdateFinal()
'
' UpdateFinal Macro
' Written 10/5/2006 to update and sort master list
'
Sheets("Master").Select
'Selects Master list
LastRow = ActiveSheet.Cells(65536, 1).End(xlUp).Row
Range("A3", ActiveSheet.Cells(LastRow, 26)).Select
Selection.Delete
'Clears all data from "Master" tab
Sheets("FoHF").Select
LastRow = ActiveSheet.Cells(65536, 1).End(xlUp).Row
Range("A3", ActiveSheet.Cells(LastRow, 26)).Select
Selection.Copy
'Copies current information from "FoHF" tab
Sheets("Master").Select
ActiveSheet.Range("A1").End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste
'Pastes to "Master" tab
Sheets("RA").Select
Application.CutCopyMode = False
LastRow = ActiveSheet.Cells(65536, 1).End(xlUp).Row
Range("A3", ActiveSheet.Cells(LastRow, 26)).Select
Selection.Copy
'Copies current information from "RA" tab
Sheets("Master").Select
ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
'Pastes to "Master" tab
Sheets("RE").Select
Application.CutCopyMode = False
LastRow = ActiveSheet.Cells(65536, 1).End(xlUp).Row
Range("A3", ActiveSheet.Cells(LastRow, 26)).Select
Selection.Copy
'Copies current information from "RE" tab
Sheets("Master").Select
ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
'Pastes to "Master" tab
Sheets("PE").Select
Application.CutCopyMode = False
LastRow = ActiveSheet.Cells(65536, 1).End(xlUp).Row
Range("A3", ActiveSheet.Cells(LastRow, 26)).Select
Selection.Copy
'Copies current information from "PE" tab
Sheets("Master").Select
ActiveSheet.Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
'Pastes to "Master" tab
Rows("3:65536").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("C3"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'Sorts alphabetically by Manager Name
End Sub

HELP!
Oct 5 '06 #1
3 1375
sashi
1,754 Expert 1GB
Hi there,

Argument not optional simply means that you are not passing enough input to your function / sub, kindly refer to below code segment, take care my fren.. :)

Expand|Select|Wrap|Line Numbers
  1.   Function TestX(ByVal strName as String, ByVal intAge as Integer)
  2.  
  3.   Msgbox strName & " - " & intAge
  4.  
  5.   End Function
  6.  
Lets refers to the above Function TestX, you need to pass to arguments, which is the Name & Age, hope you get what am trying to say, good luck.
Oct 5 '06 #2
Hi there,

Argument not optional simply means that you are not passing enough input to your function / sub, kindly refer to below code segment, take care my fren.. :)

Expand|Select|Wrap|Line Numbers
  1.   Function TestX(ByVal strName as String, ByVal intAge as Integer)
  2.  
  3.   Msgbox strName & " - " & intAge
  4.  
  5.   End Function
  6.  
Lets refers to the above Function TestX, you need to pass to arguments, which is the Name & Age, hope you get what am trying to say, good luck.
The problem is that it works for the original workbook, but causes the compiling error for the second workbook. Since the code is the same (hooray for copy paste), I don't know why the second workbook won't compile.
Oct 5 '06 #3
The error was in my variable name (lastRow). Apparently, it's been defined somewhere else in the second work book. All I had to do was declare a new long variable (lr) and replace lastRow with it. Thanks for the help
Oct 5 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Martin Bless | last post by:
I need to access a MSSQL database (MS-Sql, not MySQL!)and would very much like to use mssql-0.09.tar.gz which is available from http://www.object-craft.com.au/projects/mssql/download.html ...
21
by: hermes_917 | last post by:
I want to use memcpy to copy the contents of one struct to another which is a superset of the original struct (the second struct has extra members at the end). I wrote a small program to test...
4
by: Aaron Queenan | last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the following error message: Linking... LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport LINK : error...
0
by: David Veeneman | last post by:
Here's a problem I haven't run into before. I'm testing my site on a remote server. This morning, I changed an error message in an email, tested it locally, then used 'Copy Web Site...' to copy the...
9
by: Jess | last post by:
Hello, I tried to clear a vector "v" using "v.clear()". If "v" contains those objects that are non-built-in (e.g. string), then "clear()" can indeed remove all contents. However, if "v"...
5
by: mark_aok | last post by:
Hi all, I have a situation where I have a split database. At the back end, I need to - create a new table (I will call it newTable) with the exact fields, and relationships as another table...
2
by: renagade629 | last post by:
Can anybody help me understand what i'm doing wrong or what I'm missing? Is there anyother good and commendable C++ program I can use (free) from the internet like Dev C++? I'm having trouble doing...
4
by: MAdcock | last post by:
Hi, I have created an excel program which creates 65 or more (nneds to be unlimited) customised letters for clients. The macro uses VLOOKUP to change the details within the letter and copies /...
13
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.