Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old April 16th 19, 06:41 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2009
Posts: 55
Default Loop for text check in three colums and set a text code based on thisin another column

Simple loop required for handling a enormous amount of data
If somebody got a free moment,
thx

For a long list with data in column A till Z I want to set a text in column Z based on a part of text in three other columns. The macro should find the text within text in a cell.

In honkiedonkie explanation it is like;

-----------

Loop in column A for all rows from second to last

If (li, co+13) contains text "AAA"
and (li, co+21) contains text "BBB"
and (li, co+22) contains text "CCC"
then set (li,co+25) the text "A"

Else
If (li, co+13) contains text "DDD"
and (li, co+13) does not contains text "EEE"
and (li, co+22) contains text "FFF"
then set (li,co+25) the text "B"

end if

If (li, co+25) is empty
then set (li, co+25) the text "C"
else
end if

next li

-------------

regards, Johan




  #2   Report Post  
Old April 16th 19, 07:27 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2011
Posts: 3,668
Default Loop for text check in three colums and set a text code based on this in another column

Hi Johan,

Am Tue, 16 Apr 2019 10:41:42 -0700 (PDT) schrieb :

Loop in column A for all rows from second to last

If (li, co+13) contains text "AAA"
and (li, co+21) contains text "BBB"
and (li, co+22) contains text "CCC"
then set (li,co+25) the text "A"

Else
If (li, co+13) contains text "DDD"
and (li, co+13) does not contains text "EEE"
and (li, co+22) contains text "FFF"
then set (li,co+25) the text "B"

end if

If (li, co+25) is empty
then set (li, co+25) the text "C"
else
end if


I don't know if I understood you correctly.
If the following code does not work for your problem explain a little
more.

Sub Test()
Dim LRow As Long, i As Long
Dim varData As Variant, varOut() As Variant

With ActiveSheet
LRow = .Cells(.Rows.Count, "A").End(xlUp).Row
varData = .Range("A2:Y" & LRow)
ReDim varOut(UBound(varData) - 1)
For i = LBound(varData) To UBound(varData)
If varData(i, 14) & varData(i, 22) & varData(i, 23) = "AAABBBCCC" Then
varOut(i - 1) = "A"
ElseIf varData(i, 14) & varData(i, 23) = "DDDFFF" _
And varData(i, 22) < "EEE" Then
varOut(i - 1) = "B"
Else
varOut(i - 1) = "C"
End If
Next
.Range("Z2").Resize(UBound(varOut) + 1) =
Application.Transpose(varOut)
End With
End Sub


Regards
Claus B.
--
Windows10
Office 2016
  #3   Report Post  
Old April 16th 19, 08:10 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2009
Posts: 55
Default Loop for text check in three colums and set a text code based onthis in another column

Thanks!.

The thing thats goes wrong now is that the text in the mentioned columns isn't only the letters I wrote. Those letters are a part of the text within that specific cell.
So the text in li,co+13 could be "Blabla AAA blabla"
The text in li,co+22 could be "BBB Bla bla"
The text in li,co+23 could be "Bla CCC"

The macro has to check if the mentioned text is a part of the whole text in the cell. If in all three columns that specific text is found then...... it results in a code.

regards (and thanks!), Johan
  #4   Report Post  
Old April 17th 19, 07:27 AM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2011
Posts: 3,668
Default Loop for text check in three colums and set a text code based on this in another column

Hi Johan,

Am Tue, 16 Apr 2019 12:10:45 -0700 (PDT) schrieb :

The thing thats goes wrong now is that the text in the mentioned columns isn't only the letters I wrote. Those letters are a part of the text within that specific cell.
So the text in li,co+13 could be "Blabla AAA blabla"
The text in li,co+22 could be "BBB Bla bla"
The text in li,co+23 could be "Bla CCC"

The macro has to check if the mentioned text is a part of the whole text in the cell. If in all three columns that specific text is found then...... it results in a code.


then try:

Sub Test()
Dim LRow As Long, i As Long
Dim varData As Variant, varOut() As Variant

With ActiveSheet
LRow = .Cells(.Rows.Count, "A").End(xlUp).Row
varData = .Range("A2:Y" & LRow)
ReDim varOut(UBound(varData) - 1)
For i = LBound(varData) To UBound(varData)
If InStr(varData(i, 14), "AAA") 0 And InStr(varData(i, 22), "BBB") 0 _
And InStr(varData(i, 23), "CCC") 0 Then
varOut(i - 1) = "A"
ElseIf InStr(varData(i, 14), "DDD") 0 And InStr(varData(i, 23), "FFF") 0 _
And InStr(varData(i, 22), "EEE") = 0 Then
varOut(i - 1) = "B"
Else
varOut(i - 1) = "C"
End If
Next
.Range("Z2").Resize(UBound(varOut) + 1) = Application.Transpose(varOut)
End With
End Sub


Regards
Claus B.
--
Windows10
Office 2016
  #5   Report Post  
Old April 17th 19, 07:33 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2009
Posts: 55
Default Loop for text check in three colums and set a text code based onthis in another column

Hello Claus,

Sorry delay reaction. Long working day
Tried and a bit changed to fulfill my wishes.
It works fantastic. Also the way you created it for simple understanding.
Many many many thanks !!!

regards, Johan


Reply
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
How to subtract one text column based on their text column MS xls. Salahuddin Excel Discussion (Misc queries) 4 October 27th 08 04:57 AM
Loop through column(s) to check values, perform action based on check ward376 Excel Programming 4 November 6th 07 03:21 PM
Counting a mixed text/number column based on text in another colum Sierra Vista Steve Excel Discussion (Misc queries) 3 December 17th 06 05:30 PM
Putting text in a column based on variable text from another colum Jacky D. Excel Discussion (Misc queries) 1 December 16th 04 06:09 PM
Deleting Rows based on text in cell & formatting cell based on text in column beside it Steve Excel Programming 4 February 26th 04 03:31 PM


All times are GMT +1. The time now is 01:56 PM.

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

About Us

"It's about Microsoft Excel"

 

Copyright © 2017