Consulting

Results 1 to 3 of 3

Thread: Solved: Help needed

  1. #1
    VBAX Regular
    Joined
    Mar 2011
    Posts
    92
    Location

    Solved: Help needed

    I'm here again to seek help from the kind people on the forum.
    In the attached file, please click on the button New Day, once the form appeared click on the button " Load Last Day" and see the result: the list boxes autoselected the employees, machinery, etc. of the last day compiled.
    The code works fine but ...
    my goal would be to go back of one day for each click of the button "Load Last Day" and autoselect the correspondig employees, machinery,ecc.
    This is beyond my capabilities

    Thanks in advance for any help
    Attached Files Attached Files

  2. #2
    VBAX Regular
    Joined
    Mar 2011
    Posts
    92
    Location
    Any ideas guys?

    And first of all: its feasible?

  3. #3
    VBAX Regular
    Joined
    Mar 2011
    Posts
    92
    Location
    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
  •