PC Review


Reply
Thread Tools Rate Thread

compare two worksheets and return a corresponding column

 
 
Sai Krishna
Guest
Posts: n/a
 
      24th Jun 2008
Hi friends,

I have one sheet(say A)sheet with names of associates. These associates are
again listed in different sheets with the name of a project they are working
in shown in the adjacent column.

Names of associates are identically typed in sheet A and other sheets.

In the first sheet I would like to bring up the project they are working in
by searching different sheets.

Pl help.
Krishna



 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      24th Jun 2008
Try this code. The code will put project names in a worksheet called sub
Associates. column A contains the Associates names on all sheets. The
Project name is in Column B on all sheets except Associates.


sub getprojects()

for each sht in activeworkbook.sheets
if sht.name <> "Associates" then
RowCount = 1
Do while sht.range("A" & RowCount) <> ""
Associate = sht.range("A" & RowCount)
Project = sht.range("B" & RowCount)
With sheets("Associates")

set c = .Columns("A").Find(what:=Associate, _
lookin:=xlvalues,lookat:=xlwhole)
if c is nothing then
msgbox("Cannot find Associate : " & Associate)
else
'Find LastCol
LastCol = .cells(c.row,Columns.Count).end(xltoleft).Column
.cells(c.row,LastCol + 1) = Project
end if
end with
RowCount = RowCount + 1
Loop
end if
next sht

end sub

"Sai Krishna" wrote:

> Hi friends,
>
> I have one sheet(say A)sheet with names of associates. These associates are
> again listed in different sheets with the name of a project they are working
> in shown in the adjacent column.
>
> Names of associates are identically typed in sheet A and other sheets.
>
> In the first sheet I would like to bring up the project they are working in
> by searching different sheets.
>
> Pl help.
> Krishna
>
>
>

 
Reply With Quote
 
Sai Krishna
Guest
Posts: n/a
 
      24th Jun 2008
Hi,

this worked brilliantly!

Thanks a lot.
regards
krishna

"Joel" wrote:

> Try this code. The code will put project names in a worksheet called sub
> Associates. column A contains the Associates names on all sheets. The
> Project name is in Column B on all sheets except Associates.
>
>
> sub getprojects()
>
> for each sht in activeworkbook.sheets
> if sht.name <> "Associates" then
> RowCount = 1
> Do while sht.range("A" & RowCount) <> ""
> Associate = sht.range("A" & RowCount)
> Project = sht.range("B" & RowCount)
> With sheets("Associates")
>
> set c = .Columns("A").Find(what:=Associate, _
> lookin:=xlvalues,lookat:=xlwhole)
> if c is nothing then
> msgbox("Cannot find Associate : " & Associate)
> else
> 'Find LastCol
> LastCol = .cells(c.row,Columns.Count).end(xltoleft).Column
> .cells(c.row,LastCol + 1) = Project
> end if
> end with
> RowCount = RowCount + 1
> Loop
> end if
> next sht
>
> end sub
>
> "Sai Krishna" wrote:
>
> > Hi friends,
> >
> > I have one sheet(say A)sheet with names of associates. These associates are
> > again listed in different sheets with the name of a project they are working
> > in shown in the adjacent column.
> >
> > Names of associates are identically typed in sheet A and other sheets.
> >
> > In the first sheet I would like to bring up the project they are working in
> > by searching different sheets.
> >
> > Pl help.
> > Krishna
> >
> >
> >

 
Reply With Quote
 
ken957
Guest
Posts: n/a
 
      24th Jun 2008
This is similar two what I need to do. Where do i enter the code when I have
adapted it for my situation?
--
ken


"Joel" wrote:

> Try this code. The code will put project names in a worksheet called sub
> Associates. column A contains the Associates names on all sheets. The
> Project name is in Column B on all sheets except Associates.
>
>
> sub getprojects()
>
> for each sht in activeworkbook.sheets
> if sht.name <> "Associates" then
> RowCount = 1
> Do while sht.range("A" & RowCount) <> ""
> Associate = sht.range("A" & RowCount)
> Project = sht.range("B" & RowCount)
> With sheets("Associates")
>
> set c = .Columns("A").Find(what:=Associate, _
> lookin:=xlvalues,lookat:=xlwhole)
> if c is nothing then
> msgbox("Cannot find Associate : " & Associate)
> else
> 'Find LastCol
> LastCol = .cells(c.row,Columns.Count).end(xltoleft).Column
> .cells(c.row,LastCol + 1) = Project
> end if
> end with
> RowCount = RowCount + 1
> Loop
> end if
> next sht
>
> end sub
>
> "Sai Krishna" wrote:
>
> > Hi friends,
> >
> > I have one sheet(say A)sheet with names of associates. These associates are
> > again listed in different sheets with the name of a project they are working
> > in shown in the adjacent column.
> >
> > Names of associates are identically typed in sheet A and other sheets.
> >
> > In the first sheet I would like to bring up the project they are working in
> > by searching different sheets.
> >
> > Pl help.
> > Krishna
> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compare data from different worksheets and return matching results spmu Microsoft Excel Misc 1 11th Jul 2009 06:11 AM
Compare 2 Worksheets and return differences in a third. =?Utf-8?B?VGhlQmlnU3RpZw==?= Microsoft Excel Worksheet Functions 4 1st Nov 2007 09:06 AM
Compare text in one column to another and return a value from another. Kim Microsoft Excel Programming 4 13th May 2007 03:12 PM
How can i compare particular columns of two worksheets and get a return henson1182 Microsoft Excel Programming 2 9th May 2007 04:29 PM
compare data in the same column on separate worksheets =?Utf-8?B?am9obiBtY21pY2hhZWw=?= Microsoft Excel Worksheet Functions 1 7th Oct 2005 01:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:42 PM.