Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Copy data from one sheet to another in Excel

Dear All,
I've a excel with data. I've marked those data in 2 different color(Say Red
and Yellow). Now i would like to move data which are marked in Red Color to
another sheet in the same workbook.
Actually i'm comparing data from 2 sheets and i'm marking differed data in
Red color. Or is there any other way while comparing data itself, moving to
another sheet?

Thanks in advance,
Prabu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Copy data from one sheet to another in Excel

Use this macro:
Function is_it_red(i As Long) As Boolean
is_it_red = False
For j = 1 To Columns.count
If Cells(i, j).Interior.ColorIndex = 3 Then
is_it_red = True
Exit Function
End If
Next
End Function


Sub colorcopier()
Dim i As Long
k = 1
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.count + r.Row - 1
For i = 1 To nLastRow
If is_it_red(i) Then
Set rc = Cells(i, 1).EntireRow
Set rd = Sheets("Copy If Red #2").Cells(k, 1)
rc.Copy rd
k = k + 1
End If
Next
End Sub

Someone on this DG shared this with me a while back...now I am sharing it
with you...


Regards,
Ryan---

--
RyGuy


"Prabu" wrote:

Dear All,
I've a excel with data. I've marked those data in 2 different color(Say Red
and Yellow). Now i would like to move data which are marked in Red Color to
another sheet in the same workbook.
Actually i'm comparing data from 2 sheets and i'm marking differed data in
Red color. Or is there any other way while comparing data itself, moving to
another sheet?

Thanks in advance,
Prabu

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Copy data from one sheet to another in Excel

Thanks Ryan.. But i'm getting Run-time error '9': subscript out of range
error from this code.

"ryguy7272" wrote:

Use this macro:
Function is_it_red(i As Long) As Boolean
is_it_red = False
For j = 1 To Columns.count
If Cells(i, j).Interior.ColorIndex = 3 Then
is_it_red = True
Exit Function
End If
Next
End Function


Sub colorcopier()
Dim i As Long
k = 1
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.count + r.Row - 1
For i = 1 To nLastRow
If is_it_red(i) Then
Set rc = Cells(i, 1).EntireRow
Set rd = Sheets("Copy If Red #2").Cells(k, 1)
rc.Copy rd
k = k + 1
End If
Next
End Sub

Someone on this DG shared this with me a while back...now I am sharing it
with you...


Regards,
Ryan---

--
RyGuy


"Prabu" wrote:

Dear All,
I've a excel with data. I've marked those data in 2 different color(Say Red
and Yellow). Now i would like to move data which are marked in Red Color to
another sheet in the same workbook.
Actually i'm comparing data from 2 sheets and i'm marking differed data in
Red color. Or is there any other way while comparing data itself, moving to
another sheet?

Thanks in advance,
Prabu

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy data from one sheet to another in Excel

kindly modify the following to
Set rd = Sheets("Copy").Cells(k, 1)

thanks
ramesh


Function is_it_red(i As Long) As Boolean
is_it_red = False
For j = 1 To Columns.Count
If Cells(i, j).Interior.ColorIndex = 3 Then
is_it_red = True
Exit Function
End If
Next
End Function


Sub colorcopier()
Dim i As Long
k = 1
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
For i = 1 To nLastRow
If is_it_red(i) Then
Set rc = Cells(i, 1).EntireRow
Set rd = Sheets("Copy").Cells(k, 1)
rc.Copy rd
k = k + 1
End If
Next
End Sub

*** Sent via Developersdex http://www.developersdex.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
copy rows from one Data sheet to another sheet based on cell conte John McKeon Excel Discussion (Misc queries) 2 May 15th 10 06:49 AM
How can i copy data from a tabbed working sheet to a summary sheet StephenF Excel Discussion (Misc queries) 1 March 15th 07 03:40 PM
how to copy a cell with formula from sheet 1 (data is all vertical) into sheet 2 parag Excel Worksheet Functions 3 June 15th 06 10:29 PM
Copy data from sheet 1 to sheet 2 based on day/date [email protected] Excel Programming 7 October 1st 05 04:59 PM
excel macro to copy data to second sheet Stuart Excel Programming 8 March 19th 05 12:23 PM


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