Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy on condition and paste to last+2 row

Hi

Hope someone can help,

In the column A i have data starting at A4 which could end at any row


What i want to happen is if the data font is blue it copys the valu
and pastes it two cells down from the last cell with a value. There ma
be more than one value which is in blue font so then it should copy an
paste to the last cell + 3 etc.

I also wanted to add some predefined text when it copied it in the sam
cell. E.g. "This 'value' does not meet our criteria"

I would be grateful if anyone could also give a brief explanation o
their solution.

Thank

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy on condition and paste to last+2 row

Dim rng as Range, cell as Range
Dim rw as Long
set rng = Range(Cells(4,1),Cells(rows.count,1).end(xlup))
rw = rng(rng.rows.count)(3).row
for each cell in rng
if cell.font.colorIndex = 5 then
cell.copy destination:=cells(rw,1)
rw = rw + 1
end if
Next

if the font color is produced by conditional formatting, then you can't
check the font color directly. You would need to check the same conditions
as conditional formatting is checking.

--
Regards,
Tom Ogilvy

"infojmac " wrote in message
...
Hi

Hope someone can help,

In the column A i have data starting at A4 which could end at any row.


What i want to happen is if the data font is blue it copys the value
and pastes it two cells down from the last cell with a value. There may
be more than one value which is in blue font so then it should copy and
paste to the last cell + 3 etc.

I also wanted to add some predefined text when it copied it in the same
cell. E.g. "This 'value' does not meet our criteria"

I would be grateful if anyone could also give a brief explanation of
their solution.

Thanks


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy on condition and paste to last+2 row

info,

This is what I came up with. There will be other ways.


Charles

Sub move_text()
Dim rng As Range, finalrow As Range
Dim i As Integer
Dim firstloop As Boolean
firstloop = True
Set rng = Worksheets("sheet1").Cells(4, 1).CurrentRegion
Set finalrow = Range("A65536").End(xlUp)
For i = 1 To rng.Rows.Count
If rng(i, 1).Font.ColorIndex = 5 Then
If firstloop = True Then
finalrow.Offset(2, 0) = rng(i, 1).Value & " This is
test"
firstloop = False
Else
Set finalrow = Range("A65536").End(xlUp)
finalrow.Offset(1, 0) = rng(i, 1).Value & " This is a t"
End If
End If
Next
End Su

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy on condition and paste to last+2 row

That seems to do the job.

Thanks very much

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy on condition and paste to last+2 row

Thats done the job,

Thanks very much.


---
Message posted from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy on condition and paste to last+2 row

Thats done the job,

Thanks very much

--
Message posted from http://www.ExcelForum.com

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
wrong result Paste within same row while filtered condition applie Sherly New Users to Excel 1 December 12th 09 04:55 PM
macro to copy and paste based on a condition kathryn462 Excel Discussion (Misc queries) 5 October 14th 08 12:59 AM
Copy from one Sheet and paste on another sheet based on condition Prem Excel Discussion (Misc queries) 2 December 24th 07 05:05 AM
Copy and Paste based on Condition EJ Excel Discussion (Misc queries) 1 June 27th 07 11:17 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM


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