Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Newbie -& I am not getting this

I am getting a run error 1004 on the last line - what am I not getting?

What I want to do is go to Point "Alpha" count all the rows including but
backing out 1 for the total line then go to Sheet Extract and copy a line of
formulas (defined as range "Formula") down the sheet count number that was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Newbie -& I am not getting this

Sheets("Extract").Range("A1:" & Endrange).Copy

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"BruceG" wrote in message
...
I am getting a run error 1004 on the last line - what am I not getting?

What I want to do is go to Point "Alpha" count all the rows including but
backing out 1 for the total line then go to Sheet Extract and copy a line

of
formulas (defined as range "Formula") down the sheet count number that was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default Newbie -& I am not getting this

Change that to
Sheets("Extract").Range("A1:" & Endrange).Copy

You need to to concatenate the calculated address Endrange with the first
part instead of trying to do it the way you did. Excel is taking Endrange as
a literal the way you have it and has no clue as to what you are talking
about.

"BruceG" wrote:

I am getting a run error 1004 on the last line - what am I not getting?

What I want to do is go to Point "Alpha" count all the rows including but
backing out 1 for the total line then go to Sheet Extract and copy a line of
formulas (defined as range "Formula") down the sheet count number that was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default Newbie -& I am not getting this

If it gives you more trouble after that fix, try this instead:
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

Sometimes Excel has a problem copying what isn't selected.

"BruceG" wrote:

I am getting a run error 1004 on the last line - what am I not getting?

What I want to do is go to Point "Alpha" count all the rows including but
backing out 1 for the total line then go to Sheet Extract and copy a line of
formulas (defined as range "Formula") down the sheet count number that was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Newbie -& I am not getting this

Bob & JL, Thank for your help but it still does not work. It says Error 1004
on that line even after I tried both of y'all answers.

Could it be my whole macro be wrong and it is just hitting at the end? Here
is the latest copy -

Thanks for your help. B

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1
Endrange = "A" & j
Could this be wrong, this is not declared, should it be? What would I
call it?
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

End Sub


"JLatham" wrote:

If it gives you more trouble after that fix, try this instead:
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

Sometimes Excel has a problem copying what isn't selected.

"BruceG" wrote:

I am getting a run error 1004 on the last line - what am I not getting?

What I want to do is go to Point "Alpha" count all the rows including but
backing out 1 for the total line then go to Sheet Extract and copy a line of
formulas (defined as range "Formula") down the sheet count number that was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default Newbie -& I am not getting this

Could be that the value in i (and subsequently in j) is causing a problem.
Check the value of i, j and Endrange just before the attempt to use Endrange
to create the range to copy.

Easy way is to just insert
Stop
as a command just after the Endrange="A" & j
statement. You can then hover the cursor over the variable names and their
value will be displayed, or use the Immediate window to "Print i, j,
Endrange" (without quotes) to see what those 3 values are.
If i ends up being just 1 then j will be zero, and A0 is not a valid address.

Did you try the .Select followed by .Copy statements?

"BruceG" wrote:

Bob & JL, Thank for your help but it still does not work. It says Error 1004
on that line even after I tried both of y'all answers.

Could it be my whole macro be wrong and it is just hitting at the end? Here
is the latest copy -

Thanks for your help. B

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1
Endrange = "A" & j
Could this be wrong, this is not declared, should it be? What would I
call it?
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

End Sub


"JLatham" wrote:

If it gives you more trouble after that fix, try this instead:
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

Sometimes Excel has a problem copying what isn't selected.

"BruceG" wrote:

I am getting a run error 1004 on the last line - what am I not getting?

What I want to do is go to Point "Alpha" count all the rows including but
backing out 1 for the total line then go to Sheet Extract and copy a line of
formulas (defined as range "Formula") down the sheet count number that was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Newbie -& I am not getting this

Your current problem is that


i = Selection.End(xldown).Count

i will always equal 1 and j = i -1 is zero

so Endrange = "A0"

which is an invalid range.

I suspect what you want is

i = Selection.End(xldown).Row

--
Regards,
Tom Ogilvy



"BruceG" wrote in message
...
Bob & JL, Thank for your help but it still does not work. It says Error
1004
on that line even after I tried both of y'all answers.

Could it be my whole macro be wrong and it is just hitting at the end?
Here
is the latest copy -

Thanks for your help. B

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1
Endrange = "A" & j
Could this be wrong, this is not declared, should it be? What would I
call it?
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

End Sub


"JLatham" wrote:

If it gives you more trouble after that fix, try this instead:
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

Sometimes Excel has a problem copying what isn't selected.

"BruceG" wrote:

I am getting a run error 1004 on the last line - what am I not getting?

What I want to do is go to Point "Alpha" count all the rows including
but
backing out 1 for the total line then go to Sheet Extract and copy a
line of
formulas (defined as range "Formula") down the sheet count number that
was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Newbie -& I am not getting this

JL & Tom,

That was part of it, it was zeroing out so I changed the count to row and
adjusted my formual but it still error 1004 out on the 2nd last line. I held
my cursor over Endrange and it was showing as A46. What am I not doing right?

To recap what I am trying to do - I have data trhat is on sheet Setup I want
to know the count of rows involved of this data which varies day by day so I
can copy formulas defines as FormRow in the Extract sheet down this count.
The formulas start on Row 1 in the Extract Sheet but the data start on Row 3
of the Setup sheet.
Thanks

Bruce

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Row

j = i - 3
Endrange = "A" & j

Sheets("Extract").Range("A1:" & Endrange).Select **Error 1004 Here Endrange
came up as A46

Looking at copy syntax should I have it select range "FormRow" (a1:l1)
then copy to my destination which is the same sheet but for this example down
to a46?

Selection.Copy

End Sub


"Tom Ogilvy" wrote:

Your current problem is that


i = Selection.End(xldown).Count

i will always equal 1 and j = i -1 is zero

so Endrange = "A0"

which is an invalid range.

I suspect what you want is

i = Selection.End(xldown).Row

--
Regards,
Tom Ogilvy



"BruceG" wrote in message
...
Bob & JL, Thank for your help but it still does not work. It says Error
1004
on that line even after I tried both of y'all answers.

Could it be my whole macro be wrong and it is just hitting at the end?
Here
is the latest copy -

Thanks for your help. B

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1
Endrange = "A" & j
Could this be wrong, this is not declared, should it be? What would I
call it?
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

End Sub


"JLatham" wrote:

If it gives you more trouble after that fix, try this instead:
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

Sometimes Excel has a problem copying what isn't selected.

"BruceG" wrote:

I am getting a run error 1004 on the last line - what am I not getting?

What I want to do is go to Point "Alpha" count all the rows including
but
backing out 1 for the total line then go to Sheet Extract and copy a
line of
formulas (defined as range "Formula") down the sheet count number that
was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Newbie -& I am not getting this

You can't select a range on a sheet unless it is the active sheet.



Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).row

j = i - 2
Endrange = "A" & j
Sheets("Extract").Select
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

End Sub
------------------------------------
Better would be
-------------------------------------
Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

i = Sheets("Setup").Range("g3").End(xlDown).row - 2
Sheets("Extract").Range("A1A:" & i).Copy
Destination:=Worksheets("SomeSheet").Range("M11")



End Sub


--
Regards,
Tom Ogilvy



"BruceG" wrote in message
...
JL & Tom,

That was part of it, it was zeroing out so I changed the count to row and
adjusted my formual but it still error 1004 out on the 2nd last line. I
held
my cursor over Endrange and it was showing as A46. What am I not doing
right?

To recap what I am trying to do - I have data trhat is on sheet Setup I
want
to know the count of rows involved of this data which varies day by day so
I
can copy formulas defines as FormRow in the Extract sheet down this count.
The formulas start on Row 1 in the Extract Sheet but the data start on Row
3
of the Setup sheet.
Thanks

Bruce

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Row

j = i - 3
Endrange = "A" & j

Sheets("Extract").Range("A1:" & Endrange).Select **Error 1004 Here
Endrange
came up as A46

Looking at copy syntax should I have it select range "FormRow" (a1:l1)
then copy to my destination which is the same sheet but for this example
down
to a46?

Selection.Copy

End Sub


"Tom Ogilvy" wrote:

Your current problem is that


i = Selection.End(xldown).Count

i will always equal 1 and j = i -1 is zero

so Endrange = "A0"

which is an invalid range.

I suspect what you want is

i = Selection.End(xldown).Row

--
Regards,
Tom Ogilvy



"BruceG" wrote in message
...
Bob & JL, Thank for your help but it still does not work. It says Error
1004
on that line even after I tried both of y'all answers.

Could it be my whole macro be wrong and it is just hitting at the end?
Here
is the latest copy -

Thanks for your help. B

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j As Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1
Endrange = "A" & j
Could this be wrong, this is not declared, should it be? What
would I
call it?
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

End Sub


"JLatham" wrote:

If it gives you more trouble after that fix, try this instead:
Sheets("Extract").Range("A1:" & Endrange).Select
Selection.Copy

Sometimes Excel has a problem copying what isn't selected.

"BruceG" wrote:

I am getting a run error 1004 on the last line - what am I not
getting?

What I want to do is go to Point "Alpha" count all the rows
including
but
backing out 1 for the total line then go to Sheet Extract and copy a
line of
formulas (defined as range "Formula") down the sheet count number
that
was
just counted and adjusted by 1. USing a Click button to perform this
operation.

Any help would be greatly apprecioated.

BruceG

Private Sub CommandButton1_Click()

Dim i As Integer
Dim j as Integer

Application.Goto Reference:="Alpha"
Sheets("Setup").Range("g3").Select
i = Selection.End(xlDown).Count

j = i - 1

Endrange = "A" & j
Sheets("Extract").Range("A1:Endrange").Copy Error Line

End Sub






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
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Newbie Help. Is this possible? taltos1 Excel Discussion (Misc queries) 5 November 12th 05 04:40 PM
I'm a newbie [email protected] Excel Programming 2 June 8th 05 04:08 PM
Newbie to VBA, Can someone help me? TCrow2000 Excel Programming 4 April 20th 05 08:58 PM
newbie needs help... Dave[_48_] Excel Programming 4 October 21st 04 07:08 PM


All times are GMT +1. The time now is 03: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"