Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Help please with copy problem

Hi,

Can anyone please help with a problem I'm having copying data from one
worksheet to another?

On sheet1 I have date in cells AT1 and AT2. What I am trying do do is
copy this data from these two cells into cells in the next free row in
columns A and D in sheet2, i.e. A2 and D2, then next time A3 & D3.

The cde i'm using is:

Sheets("sheet1").Select
Range("AT1").Activate
Selection.Copy
Sheets("sheet2").Activate
Set rng = Cells(Rows.Count, "A").End(xlUp)(2)
rng.Value = Text
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False


Sheets("sheet1").Select
Range("AT2").Activate
Selection.Copy
Sheets("sheet").Activate
Set rng = Cells(Rows.Count, "D").End(xlUp)(2)
rng.Value = Text
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("sheet1").Select

The problem I'm encountering is that the data from sheet1 AT2 is
always copied into sheet 2 A2 - no sign of the data from AT1 and it
always overwrites, it doesn't copy to the next free row.

Any help/advice/suggestions would be much appreciated.


--
Cheers

Peter

Remove the INVALID to reply
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Help please with copy problem

Hi,

To begin with, your code could be significantly shorter & lots faster

Dim x As Long
'lets start at row 2
x = 2

'pasting Sheet1!AT1 to Sheet2!A2
Worksheets("sheet2").Cells(x,1).Value =
Worksheets("sheet1").Cells(1,46).Value

'pasting Sheet1!AT2 to Sheet2!D2
Worksheets("sheet2").Cells(x,4).Value =
Worksheets("sheet1").Cells(2,46).Value

By incrementing x by 1 you put the next one in the row below the
current one

ManualMan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Help please with copy problem

On 3 Nov 2004 13:16:47 -0800, "ManualMan"
wrote:

Hi,

To begin with, your code could be significantly shorter & lots faster

Dim x As Long
'lets start at row 2
x = 2

'pasting Sheet1!AT1 to Sheet2!A2
Worksheets("sheet2").Cells(x,1).Value =
Worksheets("sheet1").Cells(1,46).Value

'pasting Sheet1!AT2 to Sheet2!D2
Worksheets("sheet2").Cells(x,4).Value =
Worksheets("sheet1").Cells(2,46).Value

By incrementing x by 1 you put the next one in the row below the
current one

ManualMan


Hi ManualMan,

Thanks very much indeed, it is quick and it does work, but it's not
quite right.

Your script copies from AT1 to A2 and AT2 to D2 - that's just what
I've been struggling with. But the next time I want the data in AT2 &
AT3 to be copied to the next free row in sheet 2, i.e. A3 & D3. I had
hoped that:

Set rng = Cells(Rows.Count, "A").End(xlUp)(2)

would do the job, but it failed miserably - as usual:-)


--
Cheers

Peter

Remove the INVALID to reply
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
V-Look up copy problem-PLEASE HELP Sekhar Excel Worksheet Functions 3 September 12th 08 09:56 AM
Copy Problem WTG Excel Discussion (Misc queries) 3 March 23rd 07 10:14 PM
copy problem WTG Excel Worksheet Functions 2 March 23rd 07 09:50 PM
Copy Problem [email protected] Excel Discussion (Misc queries) 6 August 11th 05 12:45 AM
copy problem Mark K[_3_] Excel Programming 2 February 26th 04 06:11 PM


All times are GMT +1. The time now is 02:57 AM.

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"