Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to use vba to change text numbers into numerical values?
How to use vba to change text numbers into numerical values?
Two methods are recommended to convert text into numerical values:

Separate first, select the single-column data to be converted, click the separate button below the data, and then click Finish directly after the pop-up dialog box pops up. If multiple columns require multiple operations. The positions of the column buttons are as follows:

The second is the VBA method required by the landlord. This method is mainly used to solve the situation that there are too many columns to be processed. There are not many columns, so there is no need to be so complicated. Firstly, the program code for converting the whole table into numerical values is given:

Submacro 1 ()

Dim arrangement

arr=activesheet.usedrange

activesheet.usedrange=arr

End joint

Note that this code will transform the entire table. If some areas have formulas, they will also be converted into numerical values. If there are numbers with the same length as the ID number in some areas, the content will be lost after conversion. If only a certain area is converted (for example, A2:F 100), the code needs to be modified as follows:

Submacro 1 ()

Dim arrangement

arr=range("a2:f 100 ")

Range ("a2:f 100 ")= array

End joint

The program only processes one continuous area at a time, and the following loop method can be used for multiple areas (for example, A2:F 100, H3:L5):

Submacro 1 ()

Dim arrangement, rng

For each RNG in the array ("A2: f100", "H3:L5")

Arr = range (rng)

Range (rng)=arr

The next rng

End joint

This code can solve the situation of countless areas and can be written in turn according to the format.