Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
1000qlik
Partner - Contributor III
Partner - Contributor III

Macro number format thousand separator

Dear all,

I am using macros to export some tables to Excel and apply a specific format.

I am struggling with the thousand separator in the number formatting.

It should be a single quote ' and should apply to thousands and millions, if any.

Examples:

  1. 222111000 should be 222'111'000
  2. 1000 should be 1'000
  3. 999 should be 999 (the same)

I have a line code like this:

objExcelDoc.Sheets(sheetName).Columns("C:K").EntireColumn.NumberFormat = "#'##0;(#'##0)"

But the result in this:

  1. 222111'000 (missing millions separator)
  2. 1'000 (ok)
  3. '999 (no single quote should appear)

When I look at the format in Excel, there are "\" automatically added that I think are causing the issue: #\'##0;(#\'##0)

Any help would be greatly appreciated.

Thanks,

Robert

4 Replies
marcus_sommer

I think this is only possible with a conditional formating, try this:

[>=1000000]#'###'##0;[>=1000]#'##0;#

- Marcus

1000qlik
Partner - Contributor III
Partner - Contributor III
Author

Hi Marcus,

Thank you for your reply. The conditional formatting you provide works perfectly.

I would now like to format negative values within brackets and still apply the same logic for thousand separators.

Is that possible?

Thank you for your help!

Robert

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You can, but I have found the setting a little flakey. I copy the format string to the clipboard, set the thousands separator and decimal separator (even though the are correct), and then paste the format string back. Hey presto! and it works.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
1000qlik
Partner - Contributor III
Partner - Contributor III
Author

Hi Jonathan,

As long as it works I'm happy

Would you have a sample code that achieves this?

Thanks,

Robert