VBA - split semi-colon separated values on specific worksheet

albytross

New Member
Joined
Sep 22, 2021
Messages
24
Office Version
  1. 365
Hi,

I would like code which selects column A on worksheet XYZ, and separates all values.
Values are separated by semi-colons ";".

I would then like to copy the separated values from sheet XYZ and paste them into worksheet ABC, and then delete sheet XYZ.

I can work with existing code to tweak it generally, but still have no idea how to write it.. Can anyone help?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hello.
Have you tried the 'Text in Columns' menu in your Excel?... I ask because it works for what you need and without a macro.
 
Upvote 0
Hi Mario,

I recorded a macro using that function which works thanks, and managed to get copy and paste working too.

Code only works if the macro is called sequentially with my other macros. Does not work as a standalone macro because i think its not on the correct active sheet?
This was module specific code i got to work in my workbook.. I dont have the skills to make it more efficient.
Sub MagSus_SplitValues()
Set wb = ThisWorkbook
Set ws1 = wb.Worksheets("MAG_RAW_TEMP")
ws1.Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=True, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1)), TrailingMinusNumbers:= _
True
ws1.[B1] = Split("Reading1")
End Sub
 
Upvote 0
Very good research.

However, what I would do is:
- Copy that column A into the sheet that should receive the data,
- Delete the source data, and
- Apply the 'TextToColumns' to that second sheet.
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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