473,379 Members | 1,184 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

search and display a value in excel

im searching a page of products to find a certain product. the search must take the value that i have input into a certain cell then search through the like of products until in makes a match and then take details of that product and display it on a seperate page then move to the page that is displaying the details of the product. i have an idea of how to do this but as im kind of new to vba i dont know what sort of code to be using or how to search the range etc. if someone could help me out with this i would be very grateful.
Nov 23 '06 #1
2 4071
albertw
267 100+
im searching a page of products to find a certain product. the search must take the value that i have input into a certain cell then search through the like of products until in makes a match and then take details of that product and display it on a seperate page then move to the page that is displaying the details of the product. i have an idea of how to do this but as im kind of new to vba i dont know what sort of code to be using or how to search the range etc. if someone could help me out with this i would be very grateful.
hi

create an example:
sheet 1
row 1, column A = Product ID
--------, col B = Year
--------, col C = Type
--------, col D = Number
fill the cells with whatever values you like (it's just an example)

copy sheet(1) row 1 col A-D to row 1 col I-L (search part)
copy sheet(1) row 1 to sheet(2) row 1 (so create same headers)

create a button (using VB options)
give it any name (e.g: cmdSearch)

now copy and paste following code

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2. For x = 0 To 2 'max number of search columns
  3. If Not Range("i2").Offset(0, x).Value = vbNullString Then
  4. SearchValue = Range("i2").Offset(0, x).Value
  5. Exit For
  6. End If
  7. Next x
  8. For y = 0 To 6 'max vertical range of column A
  9. If Range("a1").Offset(y, x).Value = SearchValue Then
  10. cRange = Range("a1").Offset(y, 0).Address & ":" & Range("a1").Offset(y, 3).Address
  11. Sheets(2).Range("a2:d2").Value = Sheets(1).Range(cRange).Value
  12. Sheets(2).Select
  13. Exit Sub
  14. End If
  15. Next y
  16. End Sub
  17.  
fill any searchvalue under the items of I-L
if you look for a product use cell I2, for a number use cell L2
then press the button Search

first the macro looks for the first cell in range i2:l2 which has any value
assigns the right column and will compare until found
then copy the values of the entire row to sheet(2) row 2
Nov 23 '06 #2
thanks for your help it's worked just need a little tweaking to suit my program thanks again
Nov 23 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Greg | last post by:
I have a page that searches a database by a repairman's name and by a date range. It pulls info by the repairman's name but pulls all info in the database regardless of the date. Below is the code...
2
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
6
by: E Pease | last post by:
I have been trying to edit the Explorer example by Dev Ashish I found on www.msvp.org (I think). I have been all over the net so I am not quite sure where the file came from. I like the way it...
1
by: jrs_14618 | last post by:
Hello All, This post is essentially a reply a previous post/thread here on this mailing.database.myodbc group titled: MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode I was...
2
by: NasirMunir | last post by:
I have created a table in access (copied from excel). Then I created a form which contains a text field and a list box. The text field is actually a look-up field, where a user can enter a searchable...
0
by: gggram2000 | last post by:
Hi there, I'm using microsoft visual studio 2005, with c# code. I recently downloaded GemBox which is a spreadsheet for excel. I can pass parameters through textboxes, comboboxes, labels...etc...
1
by: sunnyluthra1 | last post by:
Hi Everyone, I am working on a piece of code, that displays the properties(Name, Datatype, size & Description) of the table in the database. Now I want to further Enhance the code. I Have created...
1
by: brenty66 | last post by:
I have a userform that is used as an interface for information stored on excel spreadsheets. The user enters bits of information into fields on the userform which are place on the corresponding...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.