Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to fetch rows of data across sheets dynamically


Hi all

I maintain some info that is spread across 4 sheets in a single excel
book .
In the first three I maintain employee info( empid,empname...and
other
details reg the employee) of 3 different dept.Empid is the first
column (common)of all the sheets.

Now, my requirement is, when ever I enter an empid in the first column
of the fourth sheet, and, if it already exists in any of the 3
sheets,it should
fetch the details of that employee into the fourth sheet(the complete
row). If
the empid is NOT in any of the 3 sheets, then , it should allow me to
add details of this employee in the fourth sheet.

Kindly let me know in detail as to how to go about it.

Thank You in advance.

Regards
Eddy


--
knowledgehunter
------------------------------------------------------------------------
knowledgehunter's Profile: http://www.excelforum.com/member.php...o&userid=29333
View this thread: http://www.excelforum.com/showthread...hreadid=490472

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default How to fetch rows of data across sheets dynamically

Change sheet names to suit. It is assumed that the employee info starts in
cell A1 of each of the sheets 1 to 3. If not, then change the Cells method
row parameters to suit for all range variables r1 to r3. Example:
Set r1 = ws1.Range(ws1.Cells(1, 1), c) 'Assumed info starts in A1
Set r1 = ws1.Range(ws1.Cells(5, 1), c) 'Assumed info starts in A5

This isn't likely entirely to your needs but it should get you started. This
appears to be your 3rd post on the subject.

Paste the appended code to the code module of the 4th worksheet.

Regards,
Greg

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r1 As Range, r2 As Range, r3 As Range
Dim c As Range
Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
Dim EmpId As String

If Target.Count 1 Then Exit Sub
If Target.Column 1 Then Exit Sub
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set ws3 = Sheets("Sheet3")
Set c = ws1.Cells(Rows.Count, 1).End(xlUp)
Set r1 = ws1.Range(ws1.Cells(1, 1), c)
Set c = ws2.Cells(Rows.Count, 1).End(xlUp)
Set r2 = ws2.Range(ws2.Cells(1, 1), c)
Set c = ws3.Cells(Rows.Count, 1).End(xlUp)
Set r3 = ws3.Range(ws3.Cells(1, 1), c)
EmpId = Target.Value
Set c = r1.Find(EmpId, LookAt:=xlWhole)
If c Is Nothing Then Set c = r2.Find(EmpId, LookAt:=xlWhole)
If c Is Nothing Then Set c = r3.Find(EmpId, LookAt:=xlWhole)
If c Is Nothing Then Exit Sub
Target.EntireRow.Value = c.EntireRow.Value
End Sub

"knowledgehunter" wrote:


Hi all

I maintain some info that is spread across 4 sheets in a single excel
book .
In the first three I maintain employee info( empid,empname...and
other
details reg the employee) of 3 different dept.Empid is the first
column (common)of all the sheets.

Now, my requirement is, when ever I enter an empid in the first column
of the fourth sheet, and, if it already exists in any of the 3
sheets,it should
fetch the details of that employee into the fourth sheet(the complete
row). If
the empid is NOT in any of the 3 sheets, then , it should allow me to
add details of this employee in the fourth sheet.

Kindly let me know in detail as to how to go about it.

Thank You in advance.

Regards
Eddy


--
knowledgehunter
------------------------------------------------------------------------
knowledgehunter's Profile: http://www.excelforum.com/member.php...o&userid=29333
View this thread: http://www.excelforum.com/showthread...hreadid=490472


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to fetch rows of data across sheets dynamically


Hi Greg

That works fine. Thanks a million. Now i need to work around this a bit
.. Anyway thanks once again for giving me this mighty push.

Regards,
Eddy


--
knowledgehunter
------------------------------------------------------------------------
knowledgehunter's Profile: http://www.excelforum.com/member.php...o&userid=29333
View this thread: http://www.excelforum.com/showthread...hreadid=490472

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
Can I fetch multiple rows back using VLOOKUP? Karl Rhodes Excel Worksheet Functions 1 February 26th 07 12:47 PM
Use of Indirect function to fetch data from another Excel file Boon8888 Excel Worksheet Functions 1 January 20th 06 07:46 PM
Fetching rows across sheets dynamically oola Excel Programming 0 December 2nd 05 12:27 AM
Fetching row data across sheets dynamically oola Excel Programming 0 November 30th 05 06:23 AM
Dynamically Creating Sheets Todd Huttenstine[_2_] Excel Programming 1 November 3rd 03 03:35 AM


All times are GMT +1. The time now is 08:31 AM.

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"