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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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?
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,490
Messages
6,125,094
Members
449,205
Latest member
ralemanygarcia

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
Back
Top