Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
I'm trying to make a macro that selects a given number of columns and
a variable number of rows and then copys it into a new work sheet. For some reason no matter what i do though it never works though it always stops at this line. Range(selection, selection.End(xlDown)).Select Here is the start of the macro. If you could help it would be greatly appreciated. There isen't much here but i didn't want to program to much more before i figured out this problem. Andrew Sub Macro7() ' ' Macro7 Macro ' Macro recorded 2005/03/31 by asmith2 ' ' Range("A9:E9").Select Range(selection, selection.End(xlDown)).Select selection.Copy End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
Range(selection, selection.End(xlDown)).Select
Change it to read as follows Selection.End(xlDown).Select ' ' Macro7 Macro ' Macro recorded 2005/03/31 by asmith2 ' ' Range("A9:E9").Select Range(selection, selection.End(xlDown)).Select selection.Copy End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
This is what I have now but it still breaks on the same error
Range("A9:E9").Select selection.End(xlDown).Select selection.Copy Andrew |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
Ignore the previous post, did not realise you also selected cols.
Your code is actually correct, except that you stop after copying. Why not code in the following, and see what happens: Range("<Your destination").Select ActiveSheet.Paste "Andrew T Smith" wrote: I'm trying to make a macro that selects a given number of columns and a variable number of rows and then copys it into a new work sheet. For some reason no matter what i do though it never works though it always stops at this line. Range(selection, selection.End(xlDown)).Select Here is the start of the macro. If you could help it would be greatly appreciated. There isen't much here but i didn't want to program to much more before i figured out this problem. Andrew Sub Macro7() ' ' Macro7 Macro ' Macro recorded 2005/03/31 by asmith2 ' ' Range("A9:E9").Select Range(selection, selection.End(xlDown)).Select selection.Copy End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
This would work but I have an a variable number of rows that i'm trying
to copy. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
This is where the Selection.End(xldown).Select comes in? You have selected a
specific number of columns, and with end down you are selecting the number of used rows, down to the last used one. Unless you have empty rows in between your range, of course, in which case you will have to get rid of those first. " wrote: This would work but I have an a variable number of rows that i'm trying to copy. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
ok this is what i have
Sub Macro7() ' ' Macro7 Macro ' Macro recorded 2005/03/31 by asmith2 ' ' Range("A9:E9").Select selection.End(xlDown).Select Range("sheet3").Select ActiveSheet.Paste End Sub and the error i get selects selection and says "Compile Error: Expected Function or variable" now i'm lost |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
See comments in your code, without the
" wrote: ok this is what i have Sub Macro7() ' ' Macro7 Macro ' Macro recorded 2005/03/31 by asmith2 ' ' Range("A9:E9").Select selection.End(xlDown).Select Change this to Range(Selection, Selection.End(xlDown)).Select Range("sheet3").Select ActiveSheet.Paste End Sub and the error i get selects selection and says "Compile Error: Expected Function or variable" now i'm lost |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
how to count/sum by function/macro to get the number of record to do copy/paste in macro | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |