Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a line
I have a loop that starts like this:
For Each i In Range("Data") Data is a single colum. If I wanted to copy a specific row that i was currently referencing, how would I do that? This is driving me crazy. Thanks, Mike |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a line
"ThisShouldBeEasy" wrote: I have a loop that starts like this: For Each i In Range("Data") Data is a single colum. If I wanted to copy a specific row that i was currently referencing, how would I do that? This is driving me crazy. Thanks, Mike Assuming you want to copy to another sheet For Each i In Range("Data") if i = "ref" then With Worksheet("Sheet2") set dest=cells( ,rows.count,"A").end(xlup) end with i.entireRow.copy End if next regards Peter |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a line
Peter,
That helped a lot. One more question. set dest=cells(rows.count,"A").end(xlup) This gives me the last used cell, I need the row after that. I tried + 1 but that would be easy... no dice. What do I need to do? Thanks again, Mike "PeterAtherton" wrote: "ThisShouldBeEasy" wrote: I have a loop that starts like this: For Each i In Range("Data") Data is a single colum. If I wanted to copy a specific row that i was currently referencing, how would I do that? This is driving me crazy. Thanks, Mike Assuming you want to copy to another sheet For Each i In Range("Data") if i = "ref" then With Worksheet("Sheet2") set dest=cells( ,rows.count,"A").end(xlup) end with i.entireRow.copy End if next regards Peter |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a line
That's because its out of the range defined by "Data".
Therefore, you should do something like dim x as long x = rows.count then: set dest=cells(x+1,"A").end(xlup) Cheers AShley "ThisShouldBeEasy" wrote: Peter, That helped a lot. One more question. set dest=cells(rows.count,"A").end(xlup) This gives me the last used cell, I need the row after that. I tried + 1 but that would be easy... no dice. What do I need to do? Thanks again, Mike "PeterAtherton" wrote: "ThisShouldBeEasy" wrote: I have a loop that starts like this: For Each i In Range("Data") Data is a single colum. If I wanted to copy a specific row that i was currently referencing, how would I do that? This is driving me crazy. Thanks, Mike Assuming you want to copy to another sheet For Each i In Range("Data") if i = "ref" then With Worksheet("Sheet2") set dest=cells( ,rows.count,"A").end(xlup) end with i.entireRow.copy End if next regards Peter |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a line
For Each i In Range("Data")
if i = "ref" then With Worksheet("Sheet2") set dest=.cells(.rows.count,"A").end(xlup).offset(1,0) end with i.entireRow.copy End if next i I added some dots so that the ranges refered to the previous With object (sheet2). ThisShouldBeEasy wrote: Peter, That helped a lot. One more question. set dest=cells(rows.count,"A").end(xlup) This gives me the last used cell, I need the row after that. I tried + 1 but that would be easy... no dice. What do I need to do? Thanks again, Mike "PeterAtherton" wrote: "ThisShouldBeEasy" wrote: I have a loop that starts like this: For Each i In Range("Data") Data is a single colum. If I wanted to copy a specific row that i was currently referencing, how would I do that? This is driving me crazy. Thanks, Mike Assuming you want to copy to another sheet For Each i In Range("Data") if i = "ref" then With Worksheet("Sheet2") set dest=cells( ,rows.count,"A").end(xlup) end with i.entireRow.copy End if next regards Peter -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying text with more than one line | Excel Worksheet Functions | |||
How to convert a dotted line to a solid line in a line graph | Charts and Charting in Excel | |||
Problem: Copying a cell that contains line breaks adds extra quotes | Excel Discussion (Misc queries) | |||
Copying line from one sheet to another based on given criteria | Excel Worksheet Functions | |||
Macro problem on, Yellowed line - previous line or next line. | Excel Programming |