ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Search in cell (https://www.excelbanter.com/excel-discussion-misc-queries/207189-search-cell.html)

Paul Dennis

Search in cell
 
Hi,

I have done a before and after to help

I have several columns of data. Column A is blank and I want to populate it
from column B but only when column B has "WI" as the first 2 characters.
If it does copy the contents from column from position 4 in the cell into
Column A. This column then needs to be populated down until the next WI is
found in column B.

Can you help?

BEFORE

Col A Col B Col C
WI: Ab23
John data
JIM data
WI: sd34

AFTER

Col A Col B Col C
Ab23 John data
Ab23 JIM data
sd34

Bernard Liengme

Search in cell
 
With the first WI:Ab23 in row 2
Use in A2: =IF(LEFT(B2,2)="WI",MID(B2,4,255),A1)
Copy down the column

With the first WI:Ab23 in row 1
In A1 use: =MID(B1,4,255)
Use in A2: =IF(LEFT(B2,2)="WI",MID(B2,4,255),A1)
Copy down the column

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Paul Dennis" wrote in message
...
Hi,

I have done a before and after to help

I have several columns of data. Column A is blank and I want to populate
it
from column B but only when column B has "WI" as the first 2 characters.
If it does copy the contents from column from position 4 in the cell into
Column A. This column then needs to be populated down until the next WI is
found in column B.

Can you help?

BEFORE

Col A Col B Col C
WI: Ab23
John data
JIM data
WI: sd34

AFTER

Col A Col B Col C
Ab23 John data
Ab23 JIM data
sd34




muddan madhu

Search in cell
 
try this

leave first row blank.

In cell A2 put this formula and drag it down.

=IF(LEFT(B2,2)="WI",MID(B2,FIND(":",B2)+1,255),A1)



On Oct 21, 6:34*pm, Paul Dennis
wrote:
Hi,

I have done a before and after to help

I have several columns of data. Column A is blank and I want to populate it
from column B but only when column B has "WI" as the first 2 characters.
If it does copy the contents from column from position 4 in the cell into
Column A. This column then needs to be populated down until the next WI is
found in column B.

Can you help?

BEFORE

Col A * * Col B * * * * Col C
* * * * * * * WI: Ab23
* * * * * * * John * * * * *data
* * * * * * * JIM * * * * * *data
* * * * * * * WI: sd34

AFTER

Col A * * Col B * * * * Col C
Ab23 * *John * * * * *data
Ab23 * *JIM * * * * * *data
sd34



Paul Dennis

Search in cell
 
Thx for this, however I'm doing it in a Macro???

"Bernard Liengme" wrote:

With the first WI:Ab23 in row 2
Use in A2: =IF(LEFT(B2,2)="WI",MID(B2,4,255),A1)
Copy down the column

With the first WI:Ab23 in row 1
In A1 use: =MID(B1,4,255)
Use in A2: =IF(LEFT(B2,2)="WI",MID(B2,4,255),A1)
Copy down the column

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Paul Dennis" wrote in message
...
Hi,

I have done a before and after to help

I have several columns of data. Column A is blank and I want to populate
it
from column B but only when column B has "WI" as the first 2 characters.
If it does copy the contents from column from position 4 in the cell into
Column A. This column then needs to be populated down until the next WI is
found in column B.

Can you help?

BEFORE

Col A Col B Col C
WI: Ab23
John data
JIM data
WI: sd34

AFTER

Col A Col B Col C
Ab23 John data
Ab23 JIM data
sd34





Paul Dennis

Search in cell
 
No I mean I have a macro to do this, hence I can't actually put anything in a
call. I want to be able to call a macro to do the job.

"muddan madhu" wrote:

try this

leave first row blank.

In cell A2 put this formula and drag it down.

=IF(LEFT(B2,2)="WI",MID(B2,FIND(":",B2)+1,255),A1)



On Oct 21, 6:34 pm, Paul Dennis
wrote:
Hi,

I have done a before and after to help

I have several columns of data. Column A is blank and I want to populate it
from column B but only when column B has "WI" as the first 2 characters.
If it does copy the contents from column from position 4 in the cell into
Column A. This column then needs to be populated down until the next WI is
found in column B.

Can you help?

BEFORE

Col A Col B Col C
WI: Ab23
John data
JIM data
WI: sd34

AFTER

Col A Col B Col C
Ab23 John data
Ab23 JIM data
sd34




Bernard Liengme

Search in cell
 
Sub tryme()
mylast = Cells(Cells.Rows.Count, "B").End(xlUp).Row
For j = 1 To mylast
If Mid(Cells(j, 2), 1, 2) = "WI" Then
Cells(j, 1) = Mid(Cells(j, 2), 4, 255)
Else
Cells(j, 1) = Cells(j - 1, 1)
End If
Next
End Sub

--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Paul Dennis" wrote in message
...
Thx for this, however I'm doing it in a Macro???

"Bernard Liengme" wrote:

With the first WI:Ab23 in row 2
Use in A2: =IF(LEFT(B2,2)="WI",MID(B2,4,255),A1)
Copy down the column

With the first WI:Ab23 in row 1
In A1 use: =MID(B1,4,255)
Use in A2: =IF(LEFT(B2,2)="WI",MID(B2,4,255),A1)
Copy down the column

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Paul Dennis" wrote in message
...
Hi,

I have done a before and after to help

I have several columns of data. Column A is blank and I want to
populate
it
from column B but only when column B has "WI" as the first 2
characters.
If it does copy the contents from column from position 4 in the cell
into
Column A. This column then needs to be populated down until the next WI
is
found in column B.

Can you help?

BEFORE

Col A Col B Col C
WI: Ab23
John data
JIM data
WI: sd34

AFTER

Col A Col B Col C
Ab23 John data
Ab23 JIM data
sd34








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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com