Hi All,
Apologies for the vague title, but I currently have a problem where a routine is called from a cmb, but it misses the first line. If I go into the VBA project and run it from there the line is not skipped. I will include the code from the cmb.
cmb code:
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
If Sheet1.Visible = True Then Sheet1.Visible = False
Sheet1.Activate
Call Update_All 'this calls the update_all macro that updates all the figures on all tasks worksheet
Unload UserForm3
Sheet2.Activate
Call Protect_Sheet1
Application.ScreenUpdating = True
End Sub
Update_All code
Sub Update_All() 'this code just call all the above code for either the manual input on the Information page, or the OK
'button on the Select Nation userform.
Sheet1.Activate
With ActiveSheet
Call FHtoCal
Call FCtoCal
Call EHtoCal
Call APUCYtoCal
Call APUHrstoCal
End With
End Sub
and the FH to Cal code whree the problem lies.
Sub FHtoCal() 'The following code filters the All Tasks sheet for FH,FC,EH,APUCY,APUHrs, 2nd FC and 2nd FH.
'It then runs the calculation to divide the applicable figure from the Information sheet into the count,
'which will give a calender time. This time is rounded down.
Dim lrow As Long, rngtarget As Range
With ActiveSheet
Application.ScreenUpdating = False
lrow = .Cells(.Rows.Count, 1).End(xlUp).Row
Set rngtarget = .Range("A3:I" & lrow) 'Set begin row here
With rngtarget
.AutoFilter Field:=6, Criteria1:="FH" 'criteria
End With
rngtarget.Columns("H").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=ROUNDDOWN(((RC[-1]/'Information'!R10C2)/3),0)*3"
rngtarget.AutoFilter
Application.ScreenUpdating = True
End With
End Sub
The problem is that the figure on row 3 that should be updated with the above formula is not, but as I said if I run it from the project it works.
Any ideas??
JD
Bookmarks