-
Well, i solved the problem myself , adapting a piece of code written by p45cal in response to a my previous request for help.
For anyone interested here is the code
[vba]Dim oCell
Dim MyValue
Dim ciclo As Integer
Dim numrigaCantieri As Integer
Static FirstRowUsed As Long
Dim LastRowUsed As Long
Dim Tmp
With ActiveSheet
numrigaCantieri = Cells(Rows.Count, 15).End(xlUp).Row
If numrigaCantieri > 3 Then
If FirstRowUsed < 4 Then
FirstRowUsed = numrigaCantieri
LastRowUsed = numriga 'numriga=activesheet.CurrentRegion.Rows.Count (variable measured before in the code)
Else
If Cells(FirstRowUsed - 1, 15).Text <> "" Then
FirstRowUsed = FirstRowUsed - 1
Else
Tmp = Cells(FirstRowUsed - 1, 15).End(xlUp).Row
FirstRowUsed = Tmp
LastRowUsed = Cells(FirstRowUsed, 15).End(xlDown).Row - 1
End If
End If
End If
End With
On Error GoTo GestErr2
GestErr2:
If Err.Number = 1004 And LastRowUsed = 0 Then
MsgBox "Fine giorni precedenti!", vbExclamation
Exit Sub
End If
With cmbPersonale
For Each oCell In ActiveSheet.Range("C" & FirstRowUsed, "C" & LastRowUsed)
If oCell.Value <> "" Then MyValue = oCell.Value
For ciclo = 0 To cmbPersonale.ListCount - 1
If cmbPersonale.List(ciclo) = MyValue Then
cmbPersonale.Selected(ciclo) = True
End If
Next
Next
'etc, etc.....
End With[/vba]
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