Consulting

Results 1 to 6 of 6

Thread: user form

  1. #1
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    user form

    hi,

    I have the attached file. When I copy the sheet into another new workbook below code does not work because of not seeing user form. I tried to put the modules and form into personal.xls, but it did not work.What should I do?

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Application.EnableEvents = False

    If Target.Address = "$D$1" Then
    Target.Value = Format(Date, "dd.mmmm.dddd.yyyy")
    End If

    If Target.Address = "$D$5" Then
    userform.Show
    End If

    If Target.Address = "$D$6" Then
    userform.Show
    End If
    Application.EnableEvents = True

    End Sub
    OSMAN

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Well since there is only one sheet in the workbook why not just copy the whole workbook.

    You could export the form from the first workbook and import it into the second workbook also.

    If you want it to work on every workbook(which I don't see as the case because the userform is called from specific sheet calls) you could create an addin.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    user form

    hi,

    I created an add-in and activated it but I still get the same error "object required" error line is UserForm.Show
    OSMAN

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi OSMan,
    I don't think it will be quite that simple since your calling it from sheet code...could you post your addin?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    VBAX Regular aoc's Avatar
    Joined
    Apr 2007
    Location
    Istanbul
    Posts
    90
    Location

    add-in problem

    you can try the attached add-in
    OSMAN

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I don't think it's normal to run a userform in the personal.xls from a sheet change event but I got it working like this:
    1 Put your form in personal
    2 Add a module in personal with userform.show
    [VBA]Option Explicit
    Sub ShowIt()
    UserForm.Show
    End Sub
    [/VBA]

    Then In the workbook with the worksheet change event try using this.
    [VBA]Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Application.EnableEvents = False

    If Target.Address = "$D$1" Then
    Target.Value = Format(Date, "dd.mmmm.dddd.yyyy")
    End If
    If Target.Address = "$D$5" Then
    Run "PERSONAL.XLS!ShowIt"
    End If

    If Target.Address = "$D$6" Then
    Run "PERSONAL.XLS!ShowIt"
    End If
    Application.EnableEvents = True

    End Sub[/VBA]
    You can call it the same way from an addin but you will have to call the macro in the addin that calles the userform.show.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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