Solved

Copy Combo box value to cell in Excel sheet

Posted on 2010-08-19
2
962 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
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now