Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem with a selection in a matrix-function | Excel Programming | |||
Excel problem with dynamic matrix with a name | Excel Programming | |||
Matrix Problem | Excel Discussion (Misc queries) | |||
big problem selecting and saving data | Excel Programming | |||
vba problem lookup in a matrix | Excel Programming |