ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   returning values (https://www.excelbanter.com/excel-programming/329194-returning-values.html)

3Axles

returning values
 
Hi, i am trying to modify this code so that it would be able to return values
which are not only excact matches but also values that contain the first 4
digits of the number eg at the moment if i want to find job numbers 2685,
2685-1, 2685-2 i have to do three seperate searches , however is it possible
to be able enter 2685 and have all relevant entries appear as well such as
2685-1, 2685-2
This is the current code i am using

Case 3: ' find by job number

From_Date = InputBox("Enter start date") ' Asks user to enter first
comparison date
To_Date = InputBox("Enter end date")
Job_No = InputBox("Enter Job Number")


Daily_Row_Index = 153 ' Re assign start position for Rowindex
Cells(151, 243).Value = From_Date ' Transfers date into correct
Cell($ii$151)
Cells(151, 245).Value = To_Date ' Transfers date into correct
Cell($ii$151)
Row_Index = 3 ' Row index




Today = Cells(Row_Index, date_col).Value
Main_Job_No = Cells(Row_Index, Job_Col).Value

Do While Today < "": ' Loop if there is an entry in the date column

If Today To_Date Then Exit Do ' If Main Data Date Column is greater then
end date Exit program otherwise step in

If Today = From_Date Then 'Still looping until we get a match with dates
and carryon past here but step in


If Job_No = Main_Job_No Then ' Found Match dates, Transfers Main Data into
Franklin Sheet


Cells(Daily_Row_Index, Daily_Date).Value = Cells(Row_Index, date_col).Value
Cells(Daily_Row_Index, Daily_Operator).Value =
Cells(Row_Index, Operator_Col).Value
Cells(Daily_Row_Index, Daily_Job).Value = Cells(Row_Index,
Job_Col).Value
Cells(Daily_Row_Index, Daily_Location).Value =
Cells(Row_Index, Location_Col).Value
Cells(Daily_Row_Index, Daily_Daysheet).Value =
Cells(Row_Index, Daysheet_Col).Value
Cells(Daily_Row_Index, Daily_Left).Value = Cells(Row_Index,
Left_Col).Value
Cells(Daily_Row_Index, Daily_Centre).Value =
Cells(Row_Index, Centre_Col).Value
Cells(Daily_Row_Index, Daily_Right).Value = Cells(Row_Index,
Right_Col).Value
Cells(Daily_Row_Index, Daily_Min_Paint).Value =
Cells(Row_Index, Min_Paint_Col).Value
Cells(Daily_Row_Index, Daily_Width).Value = Cells(Row_Index,
Width_Col).Value
Cells(Daily_Row_Index, Daily_Colour).Value =
Cells(Row_Index, Colour_Col).Value
Cells(Daily_Row_Index, Daily_Result).Value =
Cells(Row_Index, Result_Col).Value
Cells(Daily_Row_Index, Daily_Tester).Value =
Cells(Row_Index, Tester_Col).Value
Count_Entries = Count_Entries + 1

Daily_Row_Index = Daily_Row_Index + 1 ' Increment Sheet to
next row for new data
End If
End If

Row_Index = Row_Index + 1 ' Increment Main Data Row
Today = Cells(Row_Index, date_col).Value ' Transfer new date into
Today Variable for new comparison
Main_Job_No = Cells(Row_Index, Job_Col).Value ' Transfer new Job
Number into Main_Job_No variable few new comparison
If Count_Entries = 43 Then
MsgBox "Sorry too many entries"
Exit Do
End If
Loop
MsgBox ("All relevant entries entered into Daily Sheet")
MsgBox (Job_No & " has been used " & Count_Entries & " times between " &
From_Date & " and " & To_Date)

Thanks to anyone who takes the time to read this.
Cheers

Dick Kusleika[_4_]

returning values
 


If Job_No = Main_Job_No Then ' Found Match dates, Transfers Main Data
into Franklin Sheet


If Job_No Like Main_Job_No & "*" Then


--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com




All times are GMT +1. The time now is 05:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com