Hi,
I'm having some issues within my script that I don't seem to be able to be debug. The issue is the following;
Within my script I have to make a selection between higher and lower than 12. I started with a script looking like this:
When testing this code by itself - there is nothing wrong with it. When I have it added in with the rest of the code strange things start to happen like the age 11 is being added to my 12+ list. I feel it was because the code was moving too fast So I tried to slow it by using the code:
I've even upped it to 5 seconds.
When I couldn't get it to work I tried to add a workaround by adding the following:
Now I had a new problem. Standalone the code is doing what it is supposed to, but in the larger whole only the first 8 will receive an older or younger, the rest stays blank.
Let me point out that I've tried several lines that would help cutting performance and making the script flow better... I've tried the ones in this list:
Hopefully someone is able to help me with this problem.
I'm having some issues within my script that I don't seem to be able to be debug. The issue is the following;
Within my script I have to make a selection between higher and lower than 12. I started with a script looking like this:
VBA Code:
'for the first row is a header, start at the second.
For BooBoo = 2 To LastCell
'Select all rows that have entries that are older the 12 (so hide all others)
If Cells(BooBoo, "BP").Value < 12 Then
Rows(BooBoo).EntireRow.Hidden = True
End If
Next
'Delete all hidden rows
For iCntr = ContentRow To 1 Step -1
If Rows(iCntr).Hidden = True Then Rows(iCntr).EntireRow.Delete
Next
When testing this code by itself - there is nothing wrong with it. When I have it added in with the rest of the code strange things start to happen like the age 11 is being added to my 12+ list. I feel it was because the code was moving too fast So I tried to slow it by using the code:
VBA Code:
Application.Wait (Now + TimeValue("0:00:02"))
I've even upped it to 5 seconds.
When I couldn't get it to work I tried to add a workaround by adding the following:
VBA Code:
'for the first row is a header, start at the second.
For Tx = 2 To TheEnd
'Select all rows that have postal 6021 and are older the 12 (so hide all others)
If Cells(Tx, "BP").Value < 12 Then
Cells(Tx, "BQ").Value = "Younger"
Else
Cells(Tx, "BQ").Value = "Older"
End If
Next
'for the first row is a header, start at the second.
For BooBoo = 2 To LastCell
ActiveWindow.ScrollRow = 2
'Select all rows that have postal 6021 and are older the 12 (so hide all others)
If Cells(BooBoo, "BQ").Value = "Older" Then
Rows(BooBoo).EntireRow.Hidden = True
End If
Next
Now I had a new problem. Standalone the code is doing what it is supposed to, but in the larger whole only the first 8 will receive an older or younger, the rest stays blank.
Let me point out that I've tried several lines that would help cutting performance and making the script flow better... I've tried the ones in this list:
VBA Code:
'Turn some parameters off to improve performance
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.AutomationSecurity = msoAutomationSecurityForceDisable
screenUpdateState = Application.ScreenUpdating
statusBarState = Application.DisplayStatusBar
calcState = Application.Calculation
eventsState = Application.EnableEvents
displayPageBreakState = ActiveSheet.DisplayPageBreaks
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.Calculation = xlCalculationManual
DisplayPageBreaks = False
Hopefully someone is able to help me with this problem.