Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying Cells

I am trying to create a macro that would look at each
value in Column C of Page 1, and read the data in the 3
columns to the right of Column C, then go to Page 2 and
find the corresponding value in Column A, and then copy
the data from Columns D, E, F of Page 1 to Columns B, C, D
of Page 2. Page 2 may have multiple cells in Column A
that all have the same value, but the values in Column C
of Page 1 will never be repeated. Can someone help me
accomplish this task? Thank you very much!
JBR
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Copying Cells

One way:


Public Sub CopyOver()
Dim searchRange As Range
Dim cell As Range
Dim found As Range
Dim foundAddr As String

Application.ScreenUpdating = False
Set searchRange = Sheets("Sheet2").Range("A:A")
With Sheets("Sheet1")
For Each cell In .Range("C1:C" & _
.Range("C" & Rows.Count).End(xlUp).Row)
Set found = searchRange.Find( _
what:=cell.Value, _
LookIn:=xlValues, _
lookat:=xlWhole, _
MatchCase:=False)
If Not found Is Nothing Then
foundAddr = found.Address
Do
cell.Offset(0, 1).Resize(1, 3).Copy _
Destination:=found.Offset(0, 1)
Set found = searchRange.FindNext(after:=found)
Loop Until found.Address = foundAddr
End If
Next cell
End With
Application.ScreenUpdating = True
End Sub






In article ,
"JBR" wrote:

I am trying to create a macro that would look at each
value in Column C of Page 1, and read the data in the 3
columns to the right of Column C, then go to Page 2 and
find the corresponding value in Column A, and then copy
the data from Columns D, E, F of Page 1 to Columns B, C, D
of Page 2. Page 2 may have multiple cells in Column A
that all have the same value, but the values in Column C
of Page 1 will never be repeated. Can someone help me
accomplish this task? Thank you very much!
JBR

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Copying Cells

Another way, if you just want to copy values:

Public Sub copyover2()
Application.ScreenUpdating = False
With Sheets("Sheet2")
With .Range("B1:D" & _
.Range("A" & Rows.Count).End(xlUp).Row)
.FormulaR1C1 = _
"=IF(ISNA(MATCH(RC1,Sheet1!C3,FALSE))," & _
""""",VLOOKUP(RC1,Sheet1!C3:C6,COLUMN(),FALSE) )"
.Value = .Value
End With
End With
End Sub

In article ,
"JBR" wrote:

I am trying to create a macro that would look at each
value in Column C of Page 1, and read the data in the 3
columns to the right of Column C, then go to Page 2 and
find the corresponding value in Column A, and then copy
the data from Columns D, E, F of Page 1 to Columns B, C, D
of Page 2. Page 2 may have multiple cells in Column A
that all have the same value, but the values in Column C
of Page 1 will never be repeated. Can someone help me
accomplish this task? Thank you very much!
JBR

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 cells waterguy Excel Discussion (Misc queries) 3 November 20th 08 01:05 AM
Copying Cells DJ New Users to Excel 4 October 19th 08 12:11 AM
Copying cells phil2006 Excel Discussion (Misc queries) 5 June 7th 06 10:50 AM
How do I skip blank cells when copying over a range of cells? tawells Excel Discussion (Misc queries) 2 June 7th 05 09:36 PM
Excel should allow cloaking of certain cells when copying cells b. LDI Woody Excel Worksheet Functions 1 March 11th 05 04:55 PM


All times are GMT +1. The time now is 03:56 AM.

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"