.Value does not read whole string

Viewed 48

In my macro I need to read a value out of a Cell. The values always start with an ' followed by a number like '1 or '1001.

When I attempt to read the cell like s = wsout.Cells(headerVal(6, 1) + i, 1).Value, I only get 1 instead of '1.

wsout is a worksheet and s is defined as a String.

How do I read the actual contents of the cell?

1 Answers

You need the Range.PrefixCharacter Property whih returns the prefix character for the cell.

Here is an example

s = wsout.Cells(headerVal(6, 1) + i, 1).PrefixCharacter & _
    wsout.Cells(headerVal(6, 1) + i, 1).Value

Debug.Print s

If the cell has '1 then s above will have '1

Related