View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
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