Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Problem selecting a whole data matrix

I'm writing a macro to select and copy a large data matrix (excluding
the header row) by using the following VBA coding. Note: the row
containing the column headers is row 5.

Range("A6").Select
Dim rng2 As Range
Set rng2 = Range(ActiveCell, ActiveCell.Offset(-1,
0).End(xlToRight))
Set rng2 = Range(rng2, rng2.End(xlDown))
Selection.Copy

For some reason this code only selects the single cell A6 to be
copied. What am I doing wrong?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Problem selecting a whole data matrix

Can you look at a column to determine how many rows should be copied?

If yes, then maybe you could use:

dim LastRow as long
dim LastCol as long
with worksheets("sheet999")
'This looks at column A
lastrow = .cells(.rows.count,"A").end(xlup).row
'and looks at row 5 to find the last column
lastcol = .cells(5,.columns.count).end(xltoleft).column

.range("a5",.cells(lastrow,lastcol)).copy

'paste somewhere???

end with


wrote:

I'm writing a macro to select and copy a large data matrix (excluding
the header row) by using the following VBA coding. Note: the row
containing the column headers is row 5.

Range("A6").Select
Dim rng2 As Range
Set rng2 = Range(ActiveCell, ActiveCell.Offset(-1,
0).End(xlToRight))
Set rng2 = Range(rng2, rng2.End(xlDown))
Selection.Copy

For some reason this code only selects the single cell A6 to be
copied. What am I doing wrong?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 145
Default Problem selecting a whole data matrix

Assuming no gaps in the first row or column:

Sub tester()

With ActiveSheet.Range("A6")
Range(.End(xlDown), .End(xlToRight)).Copy
End With

End Sub


Tim


wrote in message
oups.com...
I'm writing a macro to select and copy a large data matrix (excluding
the header row) by using the following VBA coding. Note: the row
containing the column headers is row 5.

Range("A6").Select
Dim rng2 As Range
Set rng2 = Range(ActiveCell, ActiveCell.Offset(-1,
0).End(xlToRight))
Set rng2 = Range(rng2, rng2.End(xlDown))
Selection.Copy

For some reason this code only selects the single cell A6 to be
copied. What am I doing wrong?



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
Problem with a selection in a matrix-function Peter Sellmeijer Excel Programming 3 August 29th 06 02:49 AM
Excel problem with dynamic matrix with a name jgmiddel[_7_] Excel Programming 0 April 3rd 06 11:31 PM
Matrix Problem Jeff Excel Discussion (Misc queries) 1 February 4th 06 07:36 PM
big problem selecting and saving data Pierre via OfficeKB.com[_2_] Excel Programming 3 September 30th 05 11:35 PM
vba problem lookup in a matrix Jean-Pierre D via OfficeKB.com Excel Programming 6 September 1st 05 07:09 PM


All times are GMT +1. The time now is 07:32 PM.

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"