Skip to main content

How to get numbers and text from data cell in excel using vba


u face many problem to seperate the number from text in excel


here is simple way to create a formula to get result by just copy & paste

1) click alt+f11
2 )insert module


3) copy it
Function numonly(textvalue) As Variant
Dim i As Long
Dim t As Long
For i = 1 To Len(textvalue)
If IsNumeric(Mid(textvalue, i, 1)) Then
t = t & Mid(textvalue, i, 1)
End If
Next i
numonly = t
End Function 

4) paste it in  module
u get a formula which give only number in the cell

congrats u create a formula that give number from cell


similarly u get text by copying this code

Function textonly(textvalue) As String

Dim i As Long

Dim t As String

For i = 1 To Len(textvalue)

If Not IsNumeric(Mid(textvalue, i, 1)) Then

t = t & Mid(textvalue, i, 1)

End If

Next i

textonly = t

End Function





u r able to get text and number differently



Comments

Popular posts from this blog

GSTR 1 CDNR sheet Editing

You spent lots of time in structuring the CDNR sheet for future working. It easy for 1 time, took more time if you have 2 sheets but if you have more than 5 sheets then this trick helps you in time-saving and from machine work. It simple and easy  Here are the steps : Press ALT +F11 insert new module copy the code and paste in module Sub vir() Application.ScreenUpdating =false     Rows("1:4").Select     Range("O1").Activate     Selection.Delete Shift:=xlUp     ActiveSheet.Shapes.Range(Array("Picture 1")).Select     Selection.Delete     Range("C1:F1").Select     Selection.ClearContents     Range("J1:M1").Select     Selection.ClearContents     Range("A1:A2").Select     With Selection         .HorizontalAlignment = xlGeneral         .VerticalAlignment = xlCenter         .WrapText = True         .Or...

Excel Shortcut Keys

Everyone wants speed in every work, to get speed in excel you used shortcuts for different operations, which is very useful in saving time ,you become a speeder in excel ,that save lots of time Close a workbook Ctrl+W Open a workbook Ctrl+O Go to the  Home  tab Alt+H Save a workbook Ctrl+S Copy Ctrl+C Paste Ctrl+V Undo Ctrl+Z Remove cell contents Delete Choose a fill color Alt+H, H Cut Ctrl+X Go to  Insert  tab Alt+N Bold Ctrl+B Center align cell contents Alt+H, A, C Go to  Page Layout  tab Alt+P Go to  Data  tab Alt+A Go to  View  tab Alt+W Open context menu Shift+F10, o...

autofit rows and column in excel vba

Everytime we copy the data  and paste in new sheet , it get unfit . Some data unvisible and Column are not unfit .we require to column auto resize  method 1 press  CTRL + A  then press Alt then button H then button O then button I it easy but if you have many sheet method 2 copy it on module Sub autofit ()  Rows. Entirerow. Autofit Columns. Entirecolumn. Autofit  End sub