Solved

Copy Combo box value to cell in Excel sheet

Posted on 2010-08-19
2
974 Views
Last Modified: 2012-05-10
I have a combo box in a UserForm. How can I copy the value that I pick in the combo box  into a certain cell on Excel sheet? I found something similar. However, how can I do it without pressing enter as there will not be any keyboard available when the program is put on a touchscreen monitor.
Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger)

    If KeyCode = 13 Then
      Worksheets("GUI").Cells(25, 3) = TextBox2
    End If

End Sub

Open in new window

0
Comment
Question by:teeling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
kooswillem earned 250 total points
ID: 33482632
So why not just use "Worksheets("GUI").Cells(25, 3) = TextBox2"?

The "If statement with KeyCode = 13" is the "is the enter key pressed" condition.
0
 
LVL 3

Expert Comment

by:dockhand
ID: 33482924
VB.NET does not support default properties in the same manner as VB6 so I think that you will want to change TextBox2 to TextBox2.Text.  Also seeing as you were checking for the enter key you might want to move this loigc to the Validated Event instead of checking on every key stroke.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question