0

I have an APF variable store in columns apf_rev_info_col I set up its format number with 1 decimal number like this:

Columns(apf_rev_info_col).NumberFormat = "0.0"

Then I want to pick up unique value from this columns, using Application.Unique like this

unique_info = Application.Unique(Range(Cells(first_row + 1, apf_rev_info_col), Cells(last_row, apf_rev_info_col)))

but unique_info is a variant and its only keep the value of APF if APF has .0 as decimal number.

I tried unique_info(1, i).NumberFormat = "0.0" but Subscript out of range. What can I do to keep the NumberFormat in unique_info, please?

  • 4
    Format and the underlying value of a cell are two separate things. You might consider using `Format$`, as `.NumberFormat` is the property of a `Range`, and `unique_info` is not a `Range`. – BigBen Apr 12 '23 at 13:52
  • Yes exactly what I'm looking for! Thank you so much @bigben. it works like this: `unique_info(u, 1) = Format(unique_info(u, 1), "0.0")` – Le Dieu Ha PHI Apr 12 '23 at 14:32
  • 2
    Note now that you have a `Variant/String`, not a `Double`. – BigBen Apr 12 '23 at 14:33
  • Sorry for getting back in this question, but I have a case when I have only 1 `APF` so `unique_info` has only 1 element, `unique_info(1) = Format(unique_info(1), "0.0")` doesn't work. Can you help me please? @BigBen – Le Dieu Ha PHI Apr 13 '23 at 11:46
  • Try `Format$(CDbl(unique_info(1)), "0.0")`. – BigBen Apr 13 '23 at 13:18

0 Answers0