Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-26-2017, 04:25 PM
CAI TY CAI TY is offline Convert Text to Num from ComboBox.Addme to Excel Windows 10 Convert Text to Num from ComboBox.Addme to Excel Office 2016
Novice
Convert Text to Num from ComboBox.Addme to Excel
 
Join Date: Oct 2017
Posts: 1
CAI TY is on a distinguished road
Unhappy 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.
Reply With Quote
  #2  
Old 10-26-2017, 06:35 PM
macropod's Avatar
macropod macropod is offline Convert Text to Num from ComboBox.Addme to Excel Windows 7 64bit Convert Text to Num from ComboBox.Addme to Excel Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

What is the code you're already using?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-30-2017, 12:12 PM
FionaMcKenzie FionaMcKenzie is offline Convert Text to Num from ComboBox.Addme to Excel Windows 10 Convert Text to Num from ComboBox.Addme to Excel Office 2016
Novice
 
Join Date: Oct 2017
Location: Surrey, United Kingdom
Posts: 14
FionaMcKenzie is on a distinguished road
Default

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Text to Num from ComboBox.Addme to Excel Convert Drop downs to text and copying to Excel? reidthaler Word 2 09-02-2016 06:34 AM
Convert Text to Num from ComboBox.Addme to Excel Excel Combobox List VBA-User Excel Programming 4 01-07-2016 02:46 AM
Convert Text to Num from ComboBox.Addme to Excel 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
Convert Text to Num from ComboBox.Addme to Excel 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 Text to Num from ComboBox.Addme to Excel Convert lists of text in Word to excel Grosspsych Excel 5 02-06-2012 08:03 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft