Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
defining a variable-size worksheet area for copying & pasting | Excel Worksheet Functions | |||
Max size of variable? | Excel Programming | |||
any variable size | Excel Programming | |||
Variable for column selection | Excel Programming | |||
How to find out the size of a variable-size array ? | Excel Programming |