LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default how to choose a part of the text in a cell???

Hi, assuming that your data is in A2: ??2 and that you want it pasted in A1:
??1, try the following (adjusted to fit your data's location):

Sub TextSplit()
Dim Cell As Range
For Each Cell In Range("A2:" & Cells(2, Columns.Count).End(xlToLeft).Address)
Cell.Offset(-1, 0).Value = Split(Cell.Value, "_")(0)
Next Cell
End Sub

Hope this helps, but without seeing more detail (your code would be helpful)
I can't be more specific. This code will select just the data to the left of
the "_". If you want the data to the right ("BBBBB" from "AAAAA_BBBBB") then
substitute a 1 for the 0.


"Ksenija" wrote:

Hi again,
sorry, I can't make it work...

the thing is, I am trying to put this in a loop så it goes thrue a lot of
cells, så I can't specify which exact cell I am in (A1 etc)..

so I don't really knom how to make

Split(Range("A1"),"_")(0),

work...



"Jacob Skaria" wrote:

If you are looking for a fomula try the below
=LEFT(A1,FIND("_",A1)-1)

If you are looking for a VBA code; try

Split(Range("A1"),"_")(0)

or

Dim strData as String
strData = "AAAAA_BBBBB"
Msgbox Split(strData,"_")(0)

"Ksenija" wrote:

Can someone help me? If I have a text saying "AAAAA_BBBBB" in a cell, how can
I write a code that copies the text in front of "_" and pastes it in a cell
above????

So I have "AAAAA_BBBBB" and want to have AAAAA pasted in a cell above..



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
choose a cell in a range which has a text (there is only one) flying man Excel Discussion (Misc queries) 2 February 6th 09 03:43 PM
Finding text or part of a text inside the value cell [email protected] Excel Programming 1 November 23rd 07 06:19 PM
find text in cell and replace it with part of the text in that ce. jules Excel Discussion (Misc queries) 3 May 3rd 07 10:18 AM
Always keep first part of text in a cell Martin[_21_] Excel Programming 2 April 19th 07 12:50 PM
USE PART OF TEXT FROM ONE CELL IN ANOTHER Bob Excel Discussion (Misc queries) 4 December 19th 06 12:23 AM


All times are GMT +1. The time now is 11:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"