Lollygirlie1
New Member
- Joined
- Oct 5, 2006
- Messages
- 4
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!
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!