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


Hello All,

Another problem I have is in automating the number of rows down wit
which I copy a range of cells.

At present in the macro I have this bit:

Range("T5:AC5").Select
Application.CutCopyMode = False
Selection.Copy
Range("T6:T1008").Select
ActiveSheet.Paste

now rather than '1008' I want the 1008 bit to be a number that appear
in cell T1 (the number is different from sheet to sheet).

How do I do that?

Regards,
Jaime

--
jaimetimbrel
-----------------------------------------------------------------------
jaimetimbrell's Profile: http://www.excelforum.com/member.php...fo&userid=2616
View this thread: http://www.excelforum.com/showthread.php?threadid=51160

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default macro copy problem

One way:

Range("T5:AC5").Copy _
Destination:=Range("T6").Resize(Range("T1").Value, 10)

In article
,
jaimetimbrell
wrote:

Hello All,

Another problem I have is in automating the number of rows down with
which I copy a range of cells.

At present in the macro I have this bit:

Range("T5:AC5").Select
Application.CutCopyMode = False
Selection.Copy
Range("T6:T1008").Select
ActiveSheet.Paste

now rather than '1008' I want the 1008 bit to be a number that appears
in cell T1 (the number is different from sheet to sheet).

How do I do that?

Regards,
Jaime.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro copy problem


Thank you very much for your help.

It works well. I did notice it copies the formulae down 1 row too many
- could that be corrected?

Regards,
Jaime.


--
jaimetimbrell
------------------------------------------------------------------------
jaimetimbrell's Profile: http://www.excelforum.com/member.php...o&userid=26162
View this thread: http://www.excelforum.com/showthread...hreadid=511609

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default macro copy problem

One extra row doesn't make much sense. Either the value in T1 represents
the number of rows or the row to stop on. In the current case, the code is
written for the number of rows. See this demo from the immediate window
(with 1008 in T1)

? Range("T6").Resize(Range("T1").Value, 10).Address
$T$6:$AC$1013
? Range("T1").Value
1008
? Range("T6").Resize(Range("T1").Value - 5, 10).Address
$T$6:$AC$1008

adjust your code to fit what you want.

--
Regards,
Tom Ogilvy


"jaimetimbrell"
wrote in message
news:jaimetimbrell.235r1n_1139817316.661@excelforu m-nospam.com...

Thank you very much for your help.

It works well. I did notice it copies the formulae down 1 row too many
- could that be corrected?

Regards,
Jaime.


--
jaimetimbrell
------------------------------------------------------------------------
jaimetimbrell's Profile:

http://www.excelforum.com/member.php...o&userid=26162
View this thread: http://www.excelforum.com/showthread...hreadid=511609



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro copy problem


Tom,

Thanks for your help, I meant that the value in T1 was the total number
of rows I needed, so when I was applying it to the copy range I was
getting 1 row too many. When I was reading your solution I had a
brainwave (which for me was more of a brainripple!) and adjusted the
destination range in the original solution from 'T6' to T5' thereby
including the first cell and getting the correct number of rows.

I appreciate your help.

Regards,
Jaime.


--
jaimetimbrell
------------------------------------------------------------------------
jaimetimbrell's Profile: http://www.excelforum.com/member.php...o&userid=26162
View this thread: http://www.excelforum.com/showthread...hreadid=511609

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
Still Another Copy-and-Paste Macro Problem Wart Excel Discussion (Misc queries) 3 May 14th 08 01:50 AM
Copy And Paste Macro Syntax Problem Minitman Excel Worksheet Functions 2 March 27th 08 01:59 AM
macro copy problem flummi Excel Discussion (Misc queries) 1 February 13th 06 08:04 AM
macro copy problem JE McGimpsey Excel Discussion (Misc queries) 1 February 13th 06 08:03 AM
Problem with macro to copy worksheet--odd behavior DavidH[_2_] Excel Programming 0 November 1st 04 06:37 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"