Converting Scientific format into text

ankrups

Board Regular
Joined
Mar 14, 2006
Messages
127
Office Version
  1. 2021
Platform
  1. Windows
Hi,

I need to convert the format from whole columns from scientific format into text.

For example, I am receiving data from my different vendor where they provide all information in csv file. Upon receiving the file in CSV format, the barcode comes as per below formate.

SCREEN 1
1646126075288.png


I have around 8 different vendors where columns are in different places. What I need is make above format into text format as per below.
SCREEN 2
1646126157263.png


Currently I am using method as per below.
Select the whole column and then using Data>Text to columns > Selecting Delimited option and then clicking "Next" button three times. Then selecting "Text".

This process I need to do for every time and for each column which is very time consuming. I need solution that if I select any column in that tab and then run some kind of code or macro using keyboard shortcuts which can change the format to screen no2.

Thank you in advance.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
you'll need 8 macros, 1 for each vendor, and the lucky part, most of the job you can do yourself with the macro-recorder.
There is just the range to be adjusted and a little bit of "noise" to be deleted.

So can you use that macro-recorder, do the job once for a vendor and post the result (the recorded macro) here ?
 
Upvote 0
you'll need 8 macros, 1 for each vendor, and the lucky part, most of the job you can do yourself with the macro-recorder.
There is just the range to be adjusted and a little bit of "noise" to be deleted.

So can you use that macro-recorder, do the job once for a vendor and post the result (the recorded macro) here ?
Thanks for the quick reply. But I need universal approach, where one code fits for all.

Any other idea.
 
Upvote 0
this does 99% of the job.
You have to check what separator you use in the last line, adapt the source and destionation (otherwise it can be made with parameters)

VBA Code:
Sub My_Text_to_Columns()

     'prepare array fieldinfo, ADAPT TO YOUR SITUATION*********************
     Dim myArray(1 To 100, 1 To 2)                              'preparing for 100 columns
     For i = 1 To UBound(myArray)                               'loop 100 times
          myArray(i, 1) = i                                     'column
          myArray(i, 2) = 2                                     'text=2
     Next
     'suppose you have exceptions !!!!!!
     myArray(5, 2) = 1                                          '5th column, general=1
     myArray(10, 2) = 4 '10th column is date
     myArray(15, 2) = 9 'skip 15th column
     '***********************************************************

     'text to columns, range A1:A1000 to B1, with ";" as separator for 100 times as text
     Range("A1:A1000").TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:=False, Space:=False, Other:=False, FieldInfo:=myArray, TrailingMinusNumbers:=True

End Sub
 
Upvote 0
How about
VBA Code:
Sub ankrups()
   With Selection
      .TextToColumns .Rows(1), xlDelimited, xlDoubleQuote, False, False, False, False, False, False, , Array(1, 2)
   End With
End Sub
 
Upvote 0
this does 99% of the job.
You have to check what separator you use in the last line, adapt the source and destionation (otherwise it can be made with parameters)

VBA Code:
Sub My_Text_to_Columns()

     'prepare array fieldinfo, ADAPT TO YOUR SITUATION*********************
     Dim myArray(1 To 100, 1 To 2)                              'preparing for 100 columns
     For i = 1 To UBound(myArray)                               'loop 100 times
          myArray(i, 1) = i                                     'column
          myArray(i, 2) = 2                                     'text=2
     Next
     'suppose you have exceptions !!!!!!
     myArray(5, 2) = 1                                          '5th column, general=1
     myArray(10, 2) = 4 '10th column is date
     myArray(15, 2) = 9 'skip 15th column
     '***********************************************************

     'text to columns, range A1:A1000 to B1, with ";" as separator for 100 times as text
     Range("A1:A1000").TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:=False, Space:=False, Other:=False, FieldInfo:=myArray, TrailingMinusNumbers:=True

End Sub
excellent mate. This code worked very well and have used it for my one of the vendor. thank you very much.
 
Upvote 0
How about
VBA Code:
Sub ankrups()
   With Selection
      .TextToColumns .Rows(1), xlDelimited, xlDoubleQuote, False, False, False, False, False, False, , Array(1, 2)
   End With
End Sub
thanks mate. in accordance with code provided from other member, this code also helped me a lot to use in my day to day work. thanks heaps.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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