Results 1 to 8 of 8

Thread: Cannot switch between Userform to Excel Workbook

  1. #1

    Cannot switch between Userform to Excel Workbook

    I hv created Userform (maximize startups window screen). In this Userform there are several objects such as textbox. Now I need to copy data from excel to Userform. Problem is I cannot switch between this Userform and any open Excel workbook.

    If I minimize the screen manually of Userform, then I m able to copy data of excel and then again maximize the screen of Userform to paste the same.

    But this is not the solution. I want switch method i.e. "ALT + TAB" only.

    plzzzzzzzzzz help.

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    You can either write some routines that select the ranges you want to pass from the worksheet to the user form or, if you're on Office2000 up, use a modeless userform (set the Userform's ShowModal property to false)
    K :-)

  3. #3
    Hi Killian,

    thanku 4 replying. I m using office xp. ShowModal property is already set to false. I cannot write any routines which will select the ranges to pass the data bcoz ranges always keep changing...

    any other solution plz... awaiting.

  4. #4
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by ilyaskazi
    Hi Killian,

    thanku 4 replying. I m using office xp. ShowModal property is already set to false. I cannot write any routines which will select the ranges to pass the data bcoz ranges always keep changing...

    any other solution plz... awaiting.

    Hi iltaskazi,

    It doesn't matter if the ranges keep changing... Paste this into your userform module, select a cell with something written in it and show your userform. Now select another cell and left-click inside the text-box on the userform...etc.

    Option Explicit
    
    Private Sub UserForm_Activate()
    TextBox1 = Selection
    End Sub
    Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    TextBox1 = Selection
    End Sub
    Regards,
    John
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  5. #5
    Hi Killian,

    ur solution is good. It works while copying a single cell only. I need more than single cells, either selecting coloumn or row.

    thanku

  6. #6
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Hi iltaskazi,

    OK, try this...(If you have the code above in the userform module, first get rid of it or comment it out to prevent errors).

    Show the Userform, select the range you want to copy, press Ctrl+C then select the text box and press Ctrl+V, this will paste your selection into the text box. You can also do this with code, a basic way to do this is use this in the Userform module:

    Option Explicit
     
    Private Sub UserForm_Activate()
    Range("D1:D6").Select
    Selection.Copy
    TextBox1.Paste
    End Sub
    HTH,
    John
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  7. #7
    Hi Killian, John,

    Thanku very much... It was good. All is working fine.

    Thanku once again.

  8. #8
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Hi iltaskazi,

    Not a prob., just glad to see you've got it sorted.

    John

    (PS You can mark you own thread solved by clicking thread tools (above) then check Mark solved and click Perform Action...)
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

Posting Permissions

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