|
-
Apr 14th, 2008, 07:15 AM
#1
Thread Starter
New Member
Separate excel cell data into rows
I have data of multiple line in an excel cell, Separated by "Enter" (ASCII 13).
By using VBA I want to trasfer each line in to separate excel row.
e.g. Cell B2 contains data --
VS6_AIO > 0 OR VS6_DIOE > 0
VS6_QTY_B = VS6_AIO*2 IF VS6_AIO > 0 AND VS6_REDY = '2',
VS6_QTY_B = VS6_AIO IF VS6_AIO > 0 AND VS6_REDY NE '2',
VS6_QTY_B = VS6_FM IF VS6_FM > 0,
VS6_QTY_B = VS6_FM*2 IF VS6_FM > 0 AND VS6_RPSI>'Y'
I want to saparte it into row C2,C3,C4,C5,C6
Thanks
SK
-
Apr 14th, 2008, 07:18 AM
#2
Re: Separate excel cell data into rows
Thread moved from the FAQ forum, which is not the place to post your questions.
-
Apr 14th, 2008, 07:52 AM
#3
Re: Separate excel cell data into rows
 Originally Posted by kulkasac
I have data of multiple line in an excel cell, Separated by "Enter" (ASCII 13).
By using VBA I want to trasfer each line in to separate excel row.
e.g. Cell B2 contains data --
VS6_AIO > 0 OR VS6_DIOE > 0
VS6_QTY_B = VS6_AIO*2 IF VS6_AIO > 0 AND VS6_REDY = '2',
VS6_QTY_B = VS6_AIO IF VS6_AIO > 0 AND VS6_REDY NE '2',
VS6_QTY_B = VS6_FM IF VS6_FM > 0,
VS6_QTY_B = VS6_FM*2 IF VS6_FM > 0 AND VS6_RPSI>'Y'
I want to saparte it into row C2,C3,C4,C5,C6
Thanks
SK
Does this help?
vb Code:
Sub SplitMyData()
'Replace Sheet1 below with the name of the sheet
str1 = Sheets("Sheet1").Range("B2").Value
MyPos = Split(str1, vbLf)
For i = 0 To UBound(MyPos)
'(I+2) below will ensure that the data is populated
'from C2 onwards
Range("C" & (i + 2)).Value = MyPos(i)
'MsgBox MyPos(i)
Next
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 14th, 2008, 04:48 PM
#4
Re: Separate excel cell data into rows
here is some other code to do the same thing
vb Code:
arrdata = Split(Range("B2").Value, vbNewLine) Range("c2:c" & UBound(arrdata) + 2) = WorksheetFunction.Transpose(arrdata)
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|