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.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,117
Messages
5,857,477
Members
431,882
Latest member
saaaaaaaaaaaaaaaaaaaaaa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top