Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Huge problem with comparing cells in different ranges and sheets

Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on AE1 is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Huge problem with comparing cells in different ranges and sheets

1. Do you want the pasted values to begin in column B of "Data"?
2. Do you want the values pasted in their individual cells horizontally for
each name?
Or
3. Do you want the values pasted in the same cell, delimited with a space?

"Monoxito" wrote:

Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on AE1 is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Huge problem with comparing cells in different ranges and sheets


Sub copylikecells() 'from the destination sheet list in col E
For i = 2 To Cells(Rows.Count, "e").End(xlUp).Row
With Sheets("Sheet22").Columns(2)'modify to suit source
Set c = .Find(Cells(i, "e").Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
lc = Cells(i, Columns.Count).End(xlToLeft).Column + 1
c.Offset(, 1).Copy Cells(i, lc)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
Next
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Monoxito" wrote in message
...
Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on AE1 is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Huge problem with comparing cells in different ranges and sheets

Assuming you want the values to be listed in individual cells horizontally
starting in columb B.

Sub cpyVpstH()
Dim lstCol As Long
lstCol = Worksheets("Data").Cells(1, Columns.Count).End(xlToLeft).Column
Set srcRng = Worksheets("Data").Range("$A$1:$A$13")
Set Wksr = Worksheets("Report")
For Each C In srcRng
If Not C Is Nothing Then
x = C.Address
End If
a = 1
For i = 1 To 40
If C = Wksr.Cells(i, 31) Then
Wksr.Cells(i, 31).Offset(0, 1).Copy Cells(Range(x).Row, lstCol + a)
a = a + 1
End If
Next i
Next C
End Sub

"Monoxito" wrote:

Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on AE1 is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.

  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Huge problem with comparing cells in different ranges and shee

Thanks both of you for your trouble. I think it works, but it just doesn't
paste anything. Could you help me with that one?
And yes, values should be in individual cells. I need to make dynamic graph
out of this and it has quite a lot of data on it.

"JLGWhiz" kirjoitti:

Assuming you want the values to be listed in individual cells horizontally
starting in columb B.

Sub cpyVpstH()
Dim lstCol As Long
lstCol = Worksheets("Data").Cells(1, Columns.Count).End(xlToLeft).Column
Set srcRng = Worksheets("Data").Range("$A$1:$A$13")
Set Wksr = Worksheets("Report")
For Each C In srcRng
If Not C Is Nothing Then
x = C.Address
End If
a = 1
For i = 1 To 40
If C = Wksr.Cells(i, 31) Then
Wksr.Cells(i, 31).Offset(0, 1).Copy Cells(Range(x).Row, lstCol + a)
a = a + 1
End If
Next i
Next C
End Sub

"Monoxito" wrote:

Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on AE1 is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Huge problem with comparing cells in different ranges and shee

My posting was tested. You just need to adjust to YOUR data layout. It
assumes that you focus(cursor) is on the sheet of the destination list. It
assumes that this list starts on row 2 of col E. It assumes that your source
data is on sheet22 in col B and that the numbers desired are in col C.

Sub copylikecells() 'from the destination sheet list in col E
For i = 2 To Cells(Rows.Count, "e").End(xlUp).Row
With Sheets("Sheet22").Columns(2)'modify to suit source
Set c = .Find(Cells(i, "e").Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
lc = Cells(i, Columns.Count).End(xlToLeft).Column + 1
c.Offset(, 1).Copy Cells(i, lc)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
Next
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Monoxito" wrote in message
...
Thanks both of you for your trouble. I think it works, but it just doesn't
paste anything. Could you help me with that one?
And yes, values should be in individual cells. I need to make dynamic
graph
out of this and it has quite a lot of data on it.

"JLGWhiz" kirjoitti:

Assuming you want the values to be listed in individual cells
horizontally
starting in columb B.

Sub cpyVpstH()
Dim lstCol As Long
lstCol = Worksheets("Data").Cells(1, Columns.Count).End(xlToLeft).Column
Set srcRng = Worksheets("Data").Range("$A$1:$A$13")
Set Wksr = Worksheets("Report")
For Each C In srcRng
If Not C Is Nothing Then
x = C.Address
End If
a = 1
For i = 1 To 40
If C = Wksr.Cells(i, 31) Then
Wksr.Cells(i, 31).Offset(0, 1).Copy Cells(Range(x).Row, lstCol +
a)
a = a + 1
End If
Next i
Next C
End Sub

"Monoxito" wrote:

Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two
columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on AE1
is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Huge problem with comparing cells in different ranges and shee

Yes ofcourse, now it works very well. I misread and misunderstood the code
wrong. Thank you very much for your trouble.

"Don Guillett" kirjoitti:

My posting was tested. You just need to adjust to YOUR data layout. It
assumes that you focus(cursor) is on the sheet of the destination list. It
assumes that this list starts on row 2 of col E. It assumes that your source
data is on sheet22 in col B and that the numbers desired are in col C.

Sub copylikecells() 'from the destination sheet list in col E
For i = 2 To Cells(Rows.Count, "e").End(xlUp).Row
With Sheets("Sheet22").Columns(2)'modify to suit source
Set c = .Find(Cells(i, "e").Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
lc = Cells(i, Columns.Count).End(xlToLeft).Column + 1
c.Offset(, 1).Copy Cells(i, lc)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
Next
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Monoxito" wrote in message
...
Thanks both of you for your trouble. I think it works, but it just doesn't
paste anything. Could you help me with that one?
And yes, values should be in individual cells. I need to make dynamic
graph
out of this and it has quite a lot of data on it.

"JLGWhiz" kirjoitti:

Assuming you want the values to be listed in individual cells
horizontally
starting in columb B.

Sub cpyVpstH()
Dim lstCol As Long
lstCol = Worksheets("Data").Cells(1, Columns.Count).End(xlToLeft).Column
Set srcRng = Worksheets("Data").Range("$A$1:$A$13")
Set Wksr = Worksheets("Report")
For Each C In srcRng
If Not C Is Nothing Then
x = C.Address
End If
a = 1
For i = 1 To 40
If C = Wksr.Cells(i, 31) Then
Wksr.Cells(i, 31).Offset(0, 1).Copy Cells(Range(x).Row, lstCol +
a)
a = a + 1
End If
Next i
Next C
End Sub

"Monoxito" wrote:

Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two
columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on AE1
is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Huge problem with comparing cells in different ranges and shee

Glad you got it sorted out.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Monoxito" wrote in message
...
Yes ofcourse, now it works very well. I misread and misunderstood the code
wrong. Thank you very much for your trouble.

"Don Guillett" kirjoitti:

My posting was tested. You just need to adjust to YOUR data layout. It
assumes that you focus(cursor) is on the sheet of the destination list.
It
assumes that this list starts on row 2 of col E. It assumes that your
source
data is on sheet22 in col B and that the numbers desired are in col C.

Sub copylikecells() 'from the destination sheet list in col E
For i = 2 To Cells(Rows.Count, "e").End(xlUp).Row
With Sheets("Sheet22").Columns(2)'modify to suit source
Set c = .Find(Cells(i, "e").Value, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
lc = Cells(i, Columns.Count).End(xlToLeft).Column + 1
c.Offset(, 1).Copy Cells(i, lc)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
Next
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Monoxito" wrote in message
...
Thanks both of you for your trouble. I think it works, but it just
doesn't
paste anything. Could you help me with that one?
And yes, values should be in individual cells. I need to make dynamic
graph
out of this and it has quite a lot of data on it.

"JLGWhiz" kirjoitti:

Assuming you want the values to be listed in individual cells
horizontally
starting in columb B.

Sub cpyVpstH()
Dim lstCol As Long
lstCol = Worksheets("Data").Cells(1,
Columns.Count).End(xlToLeft).Column
Set srcRng = Worksheets("Data").Range("$A$1:$A$13")
Set Wksr = Worksheets("Report")
For Each C In srcRng
If Not C Is Nothing Then
x = C.Address
End If
a = 1
For i = 1 To 40
If C = Wksr.Cells(i, 31) Then
Wksr.Cells(i, 31).Offset(0, 1).Copy Cells(Range(x).Row, lstCol
+
a)
a = a + 1
End If
Next i
Next C
End Sub

"Monoxito" wrote:

Hi!
Could anyone help me with this one.
I have two sheets: "Report" and "Data". On Report-sheet I have two
columns
AE and AF. On AE there are 13 names in random order 40 times on area
"AE1:AE40" and on AF i have random values on area "AF1:AF40".
On Data-sheet I have same 13 names on area "A1:A13".
I need macro that will copy value from AF1 to AF40 if the name on
AE1
is
same as A1. And so on...Something like this:

Report-sheet Data-sheet
DA 2354 DA 2354 98 887
EA 3321 DB
FG 3214 EA 3321
DA 98 ...
DA 887
...

I've been strugling with this one over 3 days, so any help will be
appreciated.




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
Comparing two ranges on different sheets and copy matching results to new worksheet [email protected] Excel Programming 3 March 4th 07 10:41 PM
Comparing data in cells on 2 sheets mayjay Excel Discussion (Misc queries) 1 March 3rd 05 07:58 PM
Huge sheet into smaller sheets Mia[_2_] Excel Programming 1 January 28th 05 08:05 AM
Huge sheet into smaller sheets Mia Links and Linking in Excel 1 January 28th 05 07:40 AM
problem with Rows.Count and comparing cells PZipko Excel Programming 3 July 9th 04 07:33 PM


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