Datatype Conversion Macro

jsbasa

New Member
Joined
Sep 15, 2002
Messages
3
I am a newbie in creating Macros in excel although I have a proggramming knowledge using ASP and vbscript. I just want to ask a script that I can load as a macro in excel that will convert a datatype from text to general or vice versa. The amount of data that will be converted will not be the same and will not occur in the same cells.
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Can you be a bit more specific?

What do you mean by datatype text and datatype general? Convert text that looks like a number to a number (and vice versa)? Or just change the formatting?

Is there a pattern to the data you wish to convert?
 

jsbasa

New Member
Joined
Sep 15, 2002
Messages
3
The macro will change the format of each cell. From number to text. I could do it in an entire column but what if I should convert only row 3,6,9.. on a single column.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
This should get you started:

Code:
Sub Test()
    Dim Rng As Range
    Dim x As Long
    Set Rng = Range("A1:A" & Range("A65536").End(xlUp).Row)
    For x = 3 To Rng.Rows.Count Step 3
        Rng.Cells(x, 1).NumberFormat = "@"
    Next x
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,820
Messages
5,574,511
Members
412,599
Latest member
Schu94
Top