LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Greater than less than in a find function

I have a database that holds a ton of data in it and continues to grow at
astonishing rate. Therefore I have had to add extra sheets to hold the data
but my code has also had change to accomadate for all this new data.
Basically my database uses a userform to look up rep information and
populate that userform based on a zip code and a market selected by the user.
My problem lies in the fact that their can be multiple reps for the same zip
code and therefore I have well over 200,000 entries in my database. To
accomodate for this problem I have made it so all Zip codes
between(00000-19999) are on Worksheet 1, all zip codes between (20000 -
39999) are on Worksheet 2, all zip codes between (40000-59999) are on
Worksheet 3, all zip codes between (60000-79999) are on Worksheet 4, and all
zip codes between (80000-99999) are on Worksheet 5. My current code however
is only written for two worksheets with worksheet 1 having all zip codes less
than 50000 on it and Worksheet 2 having everything greater than or equal to
50000. Here is my code.

Private Sub cbFindButton_Click()
'Find Rep Info
Dim ws As Worksheet

If tbZipCode.Value < 50000 Then
Set ws = Sheet1
Else
Set ws = Sheet2
End If
With ws

Select Case cbMarket
Case "Industrial Drives"
cbMarketCol = 18
Case "Municipal Drives (W&E)"
cbMarketCol = 19
Case "HVAC"
cbMarketCol = 20
Case "Electric Utility"
cbMarketCol = 21
Case "Oil and Gas"
cbMarketCol = 22
End Select
RowCount = 1
Do While .Range("A" & RowCount) < ""
If .Range("A" & RowCount) = Val(tbZipCode.Value) And _
.Cells(RowCount, cbMarketCol) < "" Then

Set Rep = .Range("A" & RowCount)
tbRepNumber.Value = Rep.Offset(0, 1).Value
tbRepName.Value = Rep.Offset(0, 2).Value
tbRepAddress.Value = Rep.Offset(0, 3).Value
tbRepState.Value = Rep.Offset(0, 4).Value
tbRepZipCode.Value = Rep.Offset(0, 5).Value
tbRepBusPhone.Value = Rep.Offset(0, 6).Value
tbRepCellPhone.Value = Rep.Offset(0, 7).Value
tbRepFax.Value = Rep.Offset(0, 8).Value
tbSAPNumber.Value = Rep.Offset(0, 9).Value
tbRegionalManager.Value = Rep.Offset(0, 10).Value
tbRMAddress.Value = Rep.Offset(0, 11).Value
tbRMState.Value = Rep.Offset(0, 12).Value
tbRMZipCode.Value = Rep.Offset(0, 13).Value
tbRMBusPhone.Value = Rep.Offset(0, 14).Value
tbRMCellPhone.Value = Rep.Offset(0, 15).Value
tbRMFax.Value = Rep.Offset(0, 16).Value
If Rep.Offset(0, 17).Value = "x" Then cbIndustrialDrives = True
If Rep.Offset(0, 18).Value = "x" Then cbMunicipalDrives = True
If Rep.Offset(0, 19).Value = "x" Then cbHVAC = True
If Rep.Offset(0, 20).Value = "x" Then cbElectricUtility = True
If Rep.Offset(0, 21).Value = "x" Then cbOilGas = True
If Rep.Offset(0, 22).Value = "x" Then cbMediumVoltage = True
If Rep.Offset(0, 23).Value = "x" Then cbLowVoltage = True
If Rep.Offset(0, 24).Value = "x" Then cbAfterMarket = True
tbInclusions.Value = Rep.Offset(0, 25).Value
tbExclusions.Value = Rep.Offset(0, 26).Value
End If
RowCount = RowCount + 1
Loop
End With
End Sub

 
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
SMALL function to find X smallest number greater than Y kittronald Excel Worksheet Functions 6 June 15th 11 12:35 AM
CountIf Greater Than/Find Greater Than Sisilla[_2_] Excel Programming 12 October 6th 06 08:04 PM
Find minimum value greater than a particular value John Michl Excel Worksheet Functions 3 April 27th 06 07:10 PM
find first value in a row with value greater than 0 C-A Excel Discussion (Misc queries) 7 April 11th 06 09:02 PM
Find Min of a row, but only greater than zero? RocketDude Excel Worksheet Functions 3 August 17th 05 09:52 PM


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