from combobox to cell formating in currency

DB73

Board Regular
Joined
Jun 7, 2022
Messages
107
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2010
  6. 2007
Platform
  1. Windows
  2. Mobile
  3. Web
HI,

I'm struggling with the following;

i have a sheet called dumpstats that filled in via a userform
also got a sheet with data (tables) for populating the comboboxes on that userform

problem for me to solve;
i want to format the cells on the dumpstats sheet in currency (€)
i selected the column (AR) on dumpstats and set on currency.
but when cells are filled by the comboboxes the cells gettin a fault message because its filled with text and not with a number.

I use this code to write the combobox value to dumpstats sheet;
VBA Code:
Range("AR" & Rows.Count).End(xlUp).Offset(0, 0).Value = ComboBox16.Value

combobox gets populated by this code;
VBA Code:
ComboBox16.List = Application.Range("overige_declaratie").Value

the tables on the data sheets are not formatted. (does it have too ?)
only thing is, i see 46,8 instead of 46,80
I know that the comboboxes are "text"
so it doesnt matter, i think, what format these cells have.

thanks in advance.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi DB73,

always the last row in Column AR? I would add the sheetname as a qualifier to where the data should be saved. How about
VBA Code:
Sheets("dumpstats").Range("AR" & Rows.Count).End(xlUp).Value = CCur(ComboBox16.Value)
Ciao,
Holger
 
Upvote 0
Hi DB73,

always the last row in Column AR? I would add the sheetname as a qualifier to where the data should be saved. How about
VBA Code:
Sheets("dumpstats").Range("AR" & Rows.Count).End(xlUp).Value = CCur(ComboBox16.Value)
Ciao,
Holger
****..that simple...:ROFLMAO::ROFLMAO:
to push the button isn't that difficult...only to know which button to push..😇:ROFLMAO:

one thing, if i use ur code i got a fault.
if i dont use that "Sheets("dumpstats") it works :unsure:..weird...

thanks for the help anyway...works like a charm...
 
Upvote 0
Hi DB73,

if no sheet is given the code will always run on the ActiveSheet - I would always use a construct like
VBA Code:
'Using the name of the sheet which may be altered by clicking on the tab
With Worksheets("dumpstats")
  .Range("AR" & .Rows.Count).End(xlUp).Offset(1, 0).Value = CCur(ComboBox16.Value)
End With
or most likely
VBA Code:
'Using the codename of the sheet which may only be changed in the VBA or by code
'codename will only work for ThisWorkbook like presented here
With Dumpstats
  .Range("AR" & .Rows.Count).End(xlUp).Offset(1, 0).Value = CCur(ComboBox16.Value)
End With
Fine if I could be of help on this one.

Ciao,
Holger
 
Upvote 0
Solution
Hi DB73,

if no sheet is given the code will always run on the ActiveSheet - I would always use a construct like
VBA Code:
'Using the name of the sheet which may be altered by clicking on the tab
With Worksheets("dumpstats")
  .Range("AR" & .Rows.Count).End(xlUp).Offset(1, 0).Value = CCur(ComboBox16.Value)
End With
or most likely
VBA Code:
'Using the codename of the sheet which may only be changed in the VBA or by code
'codename will only work for ThisWorkbook like presented here
With Dumpstats
  .Range("AR" & .Rows.Count).End(xlUp).Offset(1, 0).Value = CCur(ComboBox16.Value)
End With
Fine if I could be of help on this one.

Ciao,
Holger

found the mistake...my bad
must be "dump stats" instead of "dumpstats"

appreciate your help...thanks
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top