Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hilight always the first item... (2000 sr-1)

    ... i hav ethis userform, is possibke in inizialize event select (hilight) always the first item of the list?

    Private Sub CommandButton1_Click()

    On Error GoTo prb
    X = MsgBox("SEI SICURO DI CARICARE " & Me.ListBox1.Text, vbYesNo)
    If X = 6 Then
    ThisWorkbook.Worksheets(Me.ListBox1.Text).Select

    Me.Hide
    End If
    Exit Sub
    prb:
    With ThisWorkbook
    For Each wks In .Worksheets
    If wks.Name = Me.ListBox1.Text Or _
    wks.Name = "SALDI" Or wks.Name = "RAPPORTI" Or wks.Name = "MENU" Or wks.Name = "PERDITE" Then
    .Worksheets(Me.ListBox1.Text).Visible = True
    .Worksheets(Me.ListBox1.Text).Select
    Else
    wks.Visible = xlSheetHidden
    End If
    Next
    End With
    If Err.Number = 9 Then
    MsgBox "SELEZIONARE!", vbInformation, "SELEZIONA ALMENO UN C/C"
    End If
    'Me.Hide
    End Sub
    Private Sub CommandButton2_Click()
    Call LOOPSHEET_PRINT
    End Sub
    Sub LOOPSHEET_PRINT()
    Application.ScreenUpdating = False

    Dim i As Long
    For i = 1 To Sheets.Count
    If Mid(Sheets(i).Name, 5, 1) = "-" Then

    Sheets(i).Activate
    Sheets(i).Visible = xlSheetVisible
    Sheets(i).Select
    ActiveWindow.SelectedSheets.PrintOut
    Sheets(i).Visible = False
    End If

    Next

    Application.ScreenUpdating = True
    Worksheets("SALDI").Select

    End Sub
    Private Sub UserForm_Initialize()
    On Error Resume Next
    Dim lb
    Dim counter As Integer, baseCount As Integer
    For Each ws In ThisWorkbook.Worksheets
    tmp = Split(ws.Name, "-")
    If UBound(tmp) > 0 Then
    Me.ListBox1.AddItem ws.Name
    End If
    Next
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: hilight always the first item... (2000 sr-1)

    At the end of the UserForm_Initialize procedure, insert this line:

    Me.ListBox1.Selected(0) = True

    (The item index starts at 0, so 0 is the first item, 1 is the second item etc.)

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: hilight always the first item... (2000 sr-1)

    tks!!! naturally work...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •