PC Review


Reply
Thread Tools Rate Thread

Copy a mamed range in one worksheet to the first blank cell in a c

 
 
Philip J Smith
Guest
Posts: n/a
 
      27th May 2009
Hi.

I have a summary report by country that is updated weekly.

I want to copy the summary data and paste them as values in the first blank
cell
in a another worksheet.

I have developed the following piece of code

Sub MoveWeeklyData()
'
Application.Goto Reference:="TotalTop"
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Worksheets("Weekly Data").Range("w_Total").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

End Sub

TotalTop := a single cell named range at the top of the column I want the
first
cell in the named range to start at.

w_Total is the named range I want to copy.

The macro stops at
Worksheets("Weekly Data").Range("w_Total").Select

With the message

Run time error '1004'

Select method of range class failed.

I would be grateful is some-one could point out the error in the code.



 
Reply With Quote
 
 
 
 
Sam Wilson
Guest
Posts: n/a
 
      27th May 2009

sub try_this()

Worksheets("Weekly Data").Range("w_Total").copy
Worksheets("WhereTotalTopIs").range("TotalTop").end(xldown).offset(1,0).pastespecial paste:=xlpastevalues

end sub

"Philip J Smith" wrote:

> Hi.
>
> I have a summary report by country that is updated weekly.
>
> I want to copy the summary data and paste them as values in the first blank
> cell
> in a another worksheet.
>
> I have developed the following piece of code
>
> Sub MoveWeeklyData()
> '
> Application.Goto Reference:="TotalTop"
> Selection.End(xlDown).Select
> ActiveCell.Offset(1, 0).Range("A1").Select
> Worksheets("Weekly Data").Range("w_Total").Select
> Selection.Copy
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
>
> End Sub
>
> TotalTop := a single cell named range at the top of the column I want the
> first
> cell in the named range to start at.
>
> w_Total is the named range I want to copy.
>
> The macro stops at
> Worksheets("Weekly Data").Range("w_Total").Select
>
> With the message
>
> Run time error '1004'
>
> Select method of range class failed.
>
> I would be grateful is some-one could point out the error in the code.
>
>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      27th May 2009
Reason being you cannot do it this way.
Worksheets("Weekly Data").Range("w_Total").Select
Either

Worksheets("Weekly Data").select
Range("w_Total").Select
or
application.goto Range("w_Total")
or, as suggested, do NOT select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Sam Wilson" <(E-Mail Removed)> wrote in message
news:31801A15-7B7A-4DC8-9DDB-(E-Mail Removed)...
>
> sub try_this()
>
> Worksheets("Weekly Data").Range("w_Total").copy
> Worksheets("WhereTotalTopIs").range("TotalTop").end(xldown).offset(1,0).pastespecial
> paste:=xlpastevalues
>
> end sub
>
> "Philip J Smith" wrote:
>
>> Hi.
>>
>> I have a summary report by country that is updated weekly.
>>
>> I want to copy the summary data and paste them as values in the first
>> blank
>> cell
>> in a another worksheet.
>>
>> I have developed the following piece of code
>>
>> Sub MoveWeeklyData()
>> '
>> Application.Goto Reference:="TotalTop"
>> Selection.End(xlDown).Select
>> ActiveCell.Offset(1, 0).Range("A1").Select
>> Worksheets("Weekly Data").Range("w_Total").Select
>> Selection.Copy
>> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
>> SkipBlanks _
>> :=False, Transpose:=False
>>
>> End Sub
>>
>> TotalTop := a single cell named range at the top of the column I want the
>> first
>> cell in the named range to start at.
>>
>> w_Total is the named range I want to copy.
>>
>> The macro stops at
>> Worksheets("Weekly Data").Range("w_Total").Select
>>
>> With the message
>>
>> Run time error '1004'
>>
>> Select method of range class failed.
>>
>> I would be grateful is some-one could point out the error in the code.
>>
>>
>>


 
Reply With Quote
 
Philip J Smith
Guest
Posts: n/a
 
      28th May 2009
Hi.

I tried this, I got an error message "Compile error: Syntax error"

Any ideas.

"Sam Wilson" wrote:

>
> sub try_this()
>
> Worksheets("Weekly Data").Range("w_Total").copy
> Worksheets("WhereTotalTopIs").range("TotalTop").end(xldown).offset(1,0).pastespecial paste:=xlpastevalues
>
> end sub
>
> "Philip J Smith" wrote:
>
> > Hi.
> >
> > I have a summary report by country that is updated weekly.
> >
> > I want to copy the summary data and paste them as values in the first blank
> > cell
> > in a another worksheet.
> >
> > I have developed the following piece of code
> >
> > Sub MoveWeeklyData()
> > '
> > Application.Goto Reference:="TotalTop"
> > Selection.End(xlDown).Select
> > ActiveCell.Offset(1, 0).Range("A1").Select
> > Worksheets("Weekly Data").Range("w_Total").Select
> > Selection.Copy
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks _
> > :=False, Transpose:=False
> >
> > End Sub
> >
> > TotalTop := a single cell named range at the top of the column I want the
> > first
> > cell in the named range to start at.
> >
> > w_Total is the named range I want to copy.
> >
> > The macro stops at
> > Worksheets("Weekly Data").Range("w_Total").Select
> >
> > With the message
> >
> > Run time error '1004'
> >
> > Select method of range class failed.
> >
> > I would be grateful is some-one could point out the error in the code.
> >
> >
> >

 
Reply With Quote
 
Philip J Smith
Guest
Posts: n/a
 
      28th May 2009
Many thanks.

"Don Guillett" wrote:

> Reason being you cannot do it this way.
> Worksheets("Weekly Data").Range("w_Total").Select
> Either
>
> Worksheets("Weekly Data").select
> Range("w_Total").Select
> or
> application.goto Range("w_Total")
> or, as suggested, do NOT select
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Sam Wilson" <(E-Mail Removed)> wrote in message
> news:31801A15-7B7A-4DC8-9DDB-(E-Mail Removed)...
> >
> > sub try_this()
> >
> > Worksheets("Weekly Data").Range("w_Total").copy
> > Worksheets("WhereTotalTopIs").range("TotalTop").end(xldown).offset(1,0).pastespecial
> > paste:=xlpastevalues
> >
> > end sub
> >
> > "Philip J Smith" wrote:
> >
> >> Hi.
> >>
> >> I have a summary report by country that is updated weekly.
> >>
> >> I want to copy the summary data and paste them as values in the first
> >> blank
> >> cell
> >> in a another worksheet.
> >>
> >> I have developed the following piece of code
> >>
> >> Sub MoveWeeklyData()
> >> '
> >> Application.Goto Reference:="TotalTop"
> >> Selection.End(xlDown).Select
> >> ActiveCell.Offset(1, 0).Range("A1").Select
> >> Worksheets("Weekly Data").Range("w_Total").Select
> >> Selection.Copy
> >> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> >> SkipBlanks _
> >> :=False, Transpose:=False
> >>
> >> End Sub
> >>
> >> TotalTop := a single cell named range at the top of the column I want the
> >> first
> >> cell in the named range to start at.
> >>
> >> w_Total is the named range I want to copy.
> >>
> >> The macro stops at
> >> Worksheets("Weekly Data").Range("w_Total").Select
> >>
> >> With the message
> >>
> >> Run time error '1004'
> >>
> >> Select method of range class failed.
> >>
> >> I would be grateful is some-one could point out the error in the code.
> >>
> >>
> >>

>
>

 
Reply With Quote
 
Philip J Smith
Guest
Posts: n/a
 
      28th May 2009
Ignore last, I worked it out.

Many thanks.

"Sam Wilson" wrote:

>
> sub try_this()
>
> Worksheets("Weekly Data").Range("w_Total").copy
> Worksheets("WhereTotalTopIs").range("TotalTop").end(xldown).offset(1,0).pastespecial paste:=xlpastevalues
>
> end sub
>
> "Philip J Smith" wrote:
>
> > Hi.
> >
> > I have a summary report by country that is updated weekly.
> >
> > I want to copy the summary data and paste them as values in the first blank
> > cell
> > in a another worksheet.
> >
> > I have developed the following piece of code
> >
> > Sub MoveWeeklyData()
> > '
> > Application.Goto Reference:="TotalTop"
> > Selection.End(xlDown).Select
> > ActiveCell.Offset(1, 0).Range("A1").Select
> > Worksheets("Weekly Data").Range("w_Total").Select
> > Selection.Copy
> > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> > SkipBlanks _
> > :=False, Transpose:=False
> >
> > End Sub
> >
> > TotalTop := a single cell named range at the top of the column I want the
> > first
> > cell in the named range to start at.
> >
> > w_Total is the named range I want to copy.
> >
> > The macro stops at
> > Worksheets("Weekly Data").Range("w_Total").Select
> >
> > With the message
> >
> > Run time error '1004'
> >
> > Select method of range class failed.
> >
> > I would be grateful is some-one could point out the error in the code.
> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy cell value into blank cells below (full worksheet) SimmoG Microsoft Excel Worksheet Functions 4 3rd Jun 2009 11:03 PM
Copy from worksheet if cell is blank Jeff Gross Microsoft Excel Programming 0 1st Jun 2009 08:35 PM
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste JenIT Microsoft Excel Programming 4 12th Apr 2007 08:56 PM
Search Range for string, then copy that cell to another worksheet =?Utf-8?B?U2hlbGx5?= Microsoft Excel Programming 1 21st Feb 2007 01:37 AM
Copy cell - fill all blank - multiple range =?Utf-8?B?Q29weSBEYXZl?= Microsoft Excel Worksheet Functions 1 17th Jul 2004 09:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:26 AM.