Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Friends,
I am trying to manipulate string in a column. The input column is represented by the following values: I_need_This_aaa I_need_This_bbb I_dont_need_this_nnn I_dont_need_this_xxx "I_need_this_ccc" not_this_yyy the resultant column i am needing should look something like this: I_need_This_aaa I_need_This_bbb I_need_this_ccc As my example represents, the initial few characters of the required string are always common. And i have 1000s of rows in this column. So, can you help me out device a method to extract the string either using a worksheet function or a VBA script. Appreciate your help. Prashant |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this code,which you may wish to adapt. It is set to read the first
10000 rows of column A. Cheers Nigel Public Sub NeedThis() Dim ir As Long Dim VBegin As Integer, VEnd As Integer Dim InString As String, OutString As String For ir = 1 To 10000 InString = RTrim(Worksheets("Sheet1").Cells(ir, 1)) If Len(InString) 0 Then VBegin = InStr(UCase(InString), "I_NEED_THIS") If VBegin 0 Then VEnd = InStr(VBegin, InString, " ") If VEnd = 0 Then VEnd = Len(InString) OutString = Mid(InString, VBegin, VEnd - VBegin + 1) Else OutString = "" End If Worksheets("Sheet1").Cells(ir, 1) = OutString End If Next ir End Sub "Prashant" wrote in message ... Friends, I am trying to manipulate string in a column. The input column is represented by the following values: I_need_This_aaa I_need_This_bbb I_dont_need_this_nnn I_dont_need_this_xxx "I_need_this_ccc" not_this_yyy the resultant column i am needing should look something like this: I_need_This_aaa I_need_This_bbb I_need_this_ccc As my example represents, the initial few characters of the required string are always common. And i have 1000s of rows in this column. So, can you help me out device a method to extract the string either using a worksheet function or a VBA script. Appreciate your help. Prashant ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I should have said it only detects the first instance of i_need_this in
each row, if there are more then you will need to modify the code to suit. Cheers N "Nigel" wrote in message ... Try this code,which you may wish to adapt. It is set to read the first 10000 rows of column A. Cheers Nigel Public Sub NeedThis() Dim ir As Long Dim VBegin As Integer, VEnd As Integer Dim InString As String, OutString As String For ir = 1 To 10000 InString = RTrim(Worksheets("Sheet1").Cells(ir, 1)) If Len(InString) 0 Then VBegin = InStr(UCase(InString), "I_NEED_THIS") If VBegin 0 Then VEnd = InStr(VBegin, InString, " ") If VEnd = 0 Then VEnd = Len(InString) OutString = Mid(InString, VBegin, VEnd - VBegin + 1) Else OutString = "" End If Worksheets("Sheet1").Cells(ir, 1) = OutString End If Next ir End Sub "Prashant" wrote in message ... Friends, I am trying to manipulate string in a column. The input column is represented by the following values: I_need_This_aaa I_need_This_bbb I_dont_need_this_nnn I_dont_need_this_xxx "I_need_this_ccc" not_this_yyy the resultant column i am needing should look something like this: I_need_This_aaa I_need_This_bbb I_need_this_ccc As my example represents, the initial few characters of the required string are always common. And i have 1000s of rows in this column. So, can you help me out device a method to extract the string either using a worksheet function or a VBA script. Appreciate your help. Prashant ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot table, IF function, calculated item versus calculated field | Excel Discussion (Misc queries) | |||
$ versus None | Excel Discussion (Misc queries) | |||
Excel 2000 versus 2003 and the TEXT Function | Excel Worksheet Functions | |||
How to plot B2:B11 versus A2:A11 | Excel Worksheet Functions | |||
"Sheet" versus "Worksheet" | Excel Programming |