#1
|
|||
|
|||
Convert Text to Num from ComboBox.Addme to Excel
I'm new to VBA - So I hope this is understandable.
ComboBox in my UserForm: cboValues: 1 2 3 4 The number is selected in the ComboBox and added to a column in Excel. The number is returned as "Text" to Excel so my pivot tables will not recognize the value. I have tried several VBA coding ideas but none have worked. I can update the Column to number format in Excel -- but when a new record is added, the cell value from cboValue still returns in Text Format. Does anyone know how to automate/fix this with VBA code? Thanks. |
#2
|
||||
|
||||
What is the code you're already using?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
You probably haven't declared your variables as a Long.
This should help as a code stub to understand what you have done wrong? Option Explicit Private Sub CommandButton1_Click() Dim lComboBox As Long, lCombBoxCount As Long lCombBoxCount = Me.ComboBox1.ListCount - 1 With ActiveSheet For lComboBox = 0 To lCombBoxCount .Cells(lComboBox + 1, 1).Value = Me.ComboBox1.List(lComboBox) Next lComboBox End With End Sub Private Sub UserForm_Initialize() Dim lComboBox As Long Me.ComboBox1.Clear For lComboBox = 1 To 10 Me.ComboBox1.AddItem lComboBox Next lComboBox End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Convert Drop downs to text and copying to Excel? | reidthaler | Word | 2 | 09-02-2016 06:34 AM |
Excel Combobox List | VBA-User | Excel Programming | 4 | 01-07-2016 02:46 AM |
Using combobox to pass data from an Excel spread sheet to text boxes on userform | Stewie840 | Word VBA | 14 | 12-17-2015 10:13 PM |
How to convert a text file to an Excel file with the data format automatically? | mradmin | Excel | 6 | 10-16-2013 10:34 AM |
Convert lists of text in Word to excel | Grosspsych | Excel | 5 | 02-06-2012 08:03 PM |