Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
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
Copying text with more than one line Noel Excel Worksheet Functions 1 July 30th 09 05:12 PM
How to convert a dotted line to a solid line in a line graph Sharlz Charts and Charting in Excel 1 January 14th 09 04:51 AM
Problem: Copying a cell that contains line breaks adds extra quotes [email protected] Excel Discussion (Misc queries) 0 November 2nd 06 07:58 PM
Copying line from one sheet to another based on given criteria Valerie Excel Worksheet Functions 2 August 2nd 06 11:02 PM
Macro problem on, Yellowed line - previous line or next line. Ed Excel Programming 7 March 29th 05 09:37 PM


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