Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying a variable selection size ?


Can someone please enlighten with a solution to this:

When I'm writing a macro in VBA and for instance I need to copy a set
of data from one place to another. - however, each time it will be run,
the number of rows of the data that is different - How can I select
just that data ??

Hope that makes sense!


--
CPhil
------------------------------------------------------------------------
CPhil's Profile: http://www.excelforum.com/member.php...o&userid=29842
View this thread: http://www.excelforum.com/showthread...hreadid=495471

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Copying a variable selection size ?

Hi,
This copies data from A2 onwards on Sheet1 to C2 (starting cell) on
Sheet2. Change as required.


HTH

Sub CopyRange()

Dim ws1 As Worksheet, ws2 As Worksheet
Dim dstrng As Range
Dim lastrow As Long

Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
Set dstrng = ws2.Range("C2")

With ws1
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("A2:A" & lastrow).Copy dstrng
End With
End Sub

"CPhil" wrote:


Can someone please enlighten with a solution to this:

When I'm writing a macro in VBA and for instance I need to copy a set
of data from one place to another. - however, each time it will be run,
the number of rows of the data that is different - How can I select
just that data ??

Hope that makes sense!


--
CPhil
------------------------------------------------------------------------
CPhil's Profile: http://www.excelforum.com/member.php...o&userid=29842
View this thread: http://www.excelforum.com/showthread...hreadid=495471


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying a variable selection size ?


thanks for the info - worked a treat


--
CPhil
------------------------------------------------------------------------
CPhil's Profile: http://www.excelforum.com/member.php...o&userid=29842
View this thread: http://www.excelforum.com/showthread...hreadid=495471

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
defining a variable-size worksheet area for copying & pasting z.entropic Excel Worksheet Functions 3 August 11th 07 09:30 PM
Max size of variable? erikcw[_4_] Excel Programming 6 December 2nd 05 06:00 PM
any variable size x taol Excel Programming 1 November 7th 05 04:51 AM
Variable for column selection Mats W. Excel Programming 2 July 14th 05 09:17 AM
How to find out the size of a variable-size array ? Adrian[_7_] Excel Programming 1 July 6th 04 09:12 AM


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