|
-
Jun 12th, 2005, 10:44 PM
#1
Thread Starter
Junior Member
How to have quicker search method?
My current searching takes a lot of time as the following code, is there any method to improve search codes especially looking into cells in excel?
I found that i use Ctrl-F , even loop fo find to the end of IV65536 column from first column, it takes less than 2 seconds, i was amazed by the speed of their searching, so i am thinking of why my looping and searching is so slow.
Code:
'/////////////////////////////////////////////////////////////////
' Update Value in Demand-PM
'////////////////////////////////////////////////////////////////
Dim rMonth As String
rMonth = Mid(Ce11.address, 2, 1)
Dim count1 As Integer
For count1 = 6 To 39
If Range("'Demand - PM'!C" & count1).Value = string1 And string1FTE = "F" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 1
''msgbox "String1FTE F deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string1 And string1FTE = "P" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.5
'msgbox "String1FTE P deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string1 And string1FTE = "Q" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.25
'msgbox "String1FTE Q deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string2 And string2FTE = "F" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 1
'msgbox "String2FTE F deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string2 And string2FTE = "P" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.5
'msgbox "String2FTE P deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string2 And string2FTE = "Q" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.25
'msgbox "String2FTE Q deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string3 And string3FTE = "F" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 1
'msgbox "String3FTE F deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string3 And string3FTE = "P" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.5
'msgbox "String3FTE P deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string3 And string3FTE = "Q" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.25
'msgbox "String3FTE Q deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string4 And string4FTE = "F" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 1
'msgbox "String4FTE F deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string4 And string4FTE = "P" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.5
'msgbox "String4FTE P deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string4 And string4FTE = "Q" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.25
'msgbox "String4FTE Q deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string5 And string5FTE = "F" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 1
'msgbox "String5FTE F deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string5 And string5FTE = "P" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.5
'msgbox "String5FTE P deleted"
End If
If Range("'Demand - PM'!C" & count1).Value = string5 And string5FTE = "Q" Then
Range("'Demand - PM'!" & rMonth & count1).Value = Range("'Demand - PM'!" & rMonth & count1).Value - 0.25
'msgbox "String5FTE Q deleted"
End If
Next
Next
'////////////////////////////////////////////////////////////////////
' Delete in PM Allocation
'////////////////////////////////////////////////////////////////////
Dim countPMAllocation, countPMAllocation2 As Integer
Dim delUpdate As Integer
Dim rmonth1 As String
Dim RangeAddress
Dim RangeAddressInt As Integer
For countPMAllocation = 6 To 50
'MsgBox ("Come to delete PM Allocation Condition")
For Each Project In Worksheets("PM Allocation").Range("B" & PrjDelCmb.Value, "O" & PrjDelCmb.Value).Cells
Project.Value = ""
'MsgBox ("Delete successful")
Next
Next
For countPMAllocation2 = 6 To 50
If Range("B" & countPMAllocation2).Value = "" Then
' MsgBox ("Come to update PM Allocation")
For Each UpdateDel In Worksheets("PM Allocation").Range("B" & countPMAllocation2, "O" & countPMAllocation2).Cells
rmonth1 = Mid(UpdateDel.address, 2, 1)
Range(rmonth1 & countPMAllocation2).Value = Range(rmonth1 & countPMAllocation2 + 1).Value
Range(rmonth1 & countPMAllocation2 + 1).Value = ""
' MsgBox ("Come to moving PM Allocation")
Next
End If
Next
'////////////////////////////////////////////////////////////////////////
' Update in Demand- Project Sheet
'////////////////////////////////////////////////////////////////////////
Dim countDemandProject, countDemandProject2 As Integer
Dim rMonth2 As String
'MsgBox ("Come to delete PM Allocation Condition")
For Each Project In Worksheets("Demand - Project").Range("B" & PrjDelCmb.Value, "O" & PrjDelCmb.Value).Cells
Project.Value = ""
'MsgBox ("Delete successful")
Next
For countDemandProject2 = 6 To 50
If Range("'Demand - Project'!B" & countDemandProject2).Value = "" Then
' MsgBox ("Come to update PM Allocation")
For Each UpdateDelProject In Worksheets("Demand - Project").Range("B" & countDemandProject2, "O" & countDemandProject2).Cells
rMonth2 = Mid(UpdateDelProject.address, 2, 1)
Range("'Demand - Project'!" & rMonth2 & countDemandProject2).Value = Range("'Demand - Project'!" & rMonth2 & countDemandProject2 + 1).Value
Range("'Demand - Project'!" & rMonth2 & countDemandProject2 + 1).Value = ""
' MsgBox ("Come to moving PM Allocation")
Next
End If
Next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Delete project in hidden flow
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For countHidden = 1 To 50
If Range("'hidden'!H" & countHidden).Value = PrjDelCmb.Value Then
Range("'hidden'!G" & countHidden).Value = ""
Range("'hidden'!H" & countHidden).Value = ""
End If
For countHidden1 = 1 To 50
If Range("'hidden'!G" & countHidden1).Value = "" Then
Range("'hidden'!G" & countHidden1).Value = Range("'hidden'!G" & countHidden1 + 1).Value
Range("'hidden'!H" & countHidden1).Value = Range("'hidden'!H" & countHidden1 + 1).Value
Range("'hidden'!H" & countHidden1).Value = Range("'hidden'!H" & countHidden1 + 1).Value - 1
Range("'hidden'!G" & countHidden1 + 1).Value = ""
Range("'hidden'!H" & countHidden1 + 1).Value = ""
End If
Next
Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|