Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Retrieving Data from another sheet

Hello, I am trying to figure out a way to make a database and I was hoping
someone could help me with a snag I hit. I am trying to create a database in
Excel. It will basically have two sheets.

One for all of the information, and the other to act as a sort of search
function. The sheet with all of the information will have several columns,
including a persons name, clothing size, shoe size, etc. What I want on the
second sheet it to be able to type the persons name (which will be column A)
and be able to search the database and show all of the information in the
rest of the columns. (For example, the name in column A2 is Joe and there are
three other columns. The search would return all of the information in
columns B2, C2 and D2)

I know that there is a way to do this, but my experience in programing with
Excel is somewhat limited. Is there anyone that can help or at least point me
in the right direction? Any help would be greatly appreciated. Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Retrieving Data from another sheet

Here is one way. The code goes in the sheet code module for sheet2. The
macro executes when a name is typed into cell A2 of sheet2.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target = Range("A2") Then
Set c = Sheets("Sheet1").Cells _
.Find(Target.Value, LookIn:=xlValues)
If Not c Is Nothing Then
MsgBox c.Value & " " & c.Offset(0, 1).Value & " " _
& c.Offset(0, 2).Value & " " & c.Offset(0, 3).Value
End If
End If
End Sub

If you want the data to appear on sheet two. Then substitute a copy
statement for the message box.

Sheets(1).Range("B" & c.Row & ":D" & c.Row).Copy Sheets(2).Range("B2")


"Mike B" wrote in message
...
Hello, I am trying to figure out a way to make a database and I was hoping
someone could help me with a snag I hit. I am trying to create a database
in
Excel. It will basically have two sheets.

One for all of the information, and the other to act as a sort of search
function. The sheet with all of the information will have several
columns,
including a persons name, clothing size, shoe size, etc. What I want on
the
second sheet it to be able to type the persons name (which will be column
A)
and be able to search the database and show all of the information in the
rest of the columns. (For example, the name in column A2 is Joe and there
are
three other columns. The search would return all of the information in
columns B2, C2 and D2)

I know that there is a way to do this, but my experience in programing
with
Excel is somewhat limited. Is there anyone that can help or at least point
me
in the right direction? Any help would be greatly appreciated. Thank you.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Retrieving Data from another sheet

To avoid a type mismatch error, change this line:

If Target = Range("A2") Then

To this:

If Target.Address = Range("A2").Address Then



"Mike B" wrote in message
...
Hello, I am trying to figure out a way to make a database and I was hoping
someone could help me with a snag I hit. I am trying to create a database
in
Excel. It will basically have two sheets.

One for all of the information, and the other to act as a sort of search
function. The sheet with all of the information will have several
columns,
including a persons name, clothing size, shoe size, etc. What I want on
the
second sheet it to be able to type the persons name (which will be column
A)
and be able to search the database and show all of the information in the
rest of the columns. (For example, the name in column A2 is Joe and there
are
three other columns. The search would return all of the information in
columns B2, C2 and D2)

I know that there is a way to do this, but my experience in programing
with
Excel is somewhat limited. Is there anyone that can help or at least point
me
in the right direction? Any help would be greatly appreciated. Thank you.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Retrieving Data from another sheet

Awesome, thanks a bunch. One last question, if I want to add more columns to
be shown, how should I modify the code (ex: instead of columns b2, c2, d2, i
want to pull through g2)? Thanks.

"JLGWhiz" wrote:

To avoid a type mismatch error, change this line:

If Target = Range("A2") Then

To this:

If Target.Address = Range("A2").Address Then



"Mike B" wrote in message
...
Hello, I am trying to figure out a way to make a database and I was hoping
someone could help me with a snag I hit. I am trying to create a database
in
Excel. It will basically have two sheets.

One for all of the information, and the other to act as a sort of search
function. The sheet with all of the information will have several
columns,
including a persons name, clothing size, shoe size, etc. What I want on
the
second sheet it to be able to type the persons name (which will be column
A)
and be able to search the database and show all of the information in the
rest of the columns. (For example, the name in column A2 is Joe and there
are
three other columns. The search would return all of the information in
columns B2, C2 and D2)

I know that there is a way to do this, but my experience in programing
with
Excel is somewhat limited. Is there anyone that can help or at least point
me
in the right direction? Any help would be greatly appreciated. Thank you.




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
macro for retrieving a set of data from excel sheet dvvkm Excel Discussion (Misc queries) 5 August 6th 07 07:46 AM
Retrieving Data: Speed of beating down rows vs retrieving from array? (PeteCresswell) Excel Programming 2 July 9th 07 03:30 PM
Need help searching another sheet and retrieving a value JeffH Excel Worksheet Functions 1 July 28th 06 03:22 AM
retrieving values from a specified sheet Anift Excel Worksheet Functions 4 April 1st 06 01:14 PM
Retrieving data from work sheet to USER FORM [email protected] Excel Programming 1 October 12th 05 12:51 AM


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