Merging Values with IF Function

Ildestino

New Member
Joined
Jun 23, 2014
Messages
15
Dear Excel Gurus,

I once pray for your wisdom as I am not worthy of this... :)

Guys, I have a question, I am trying to figure out, what is the "easiest" (besides manual) to merge values from one column to another.

to be more precise,
Column AColumn BColumn CColumn D
7 Char Description7 Char Descr. Check3 Digits Description3 Digis Descr. Check
Tab Mex
FALSEMEXTRUE
TAB BraFALSEBRATRUE
TAB ECUFALSEECUTRUE
CZE/SVKTRUE/SVKFALSE
BIH/HRVTRUE/HRVFALSE
GBR/IRLTRUE/IRLFALSE
PLR PRTFALSEPRTTRUE
PLR CANFALSECANTRUE
HUN/POLTRUE/POLFALSE

<tbody>
</tbody>


So the rule should be like this and should run to the whole worksheet.

IF Column B = TRUE than Copy Value of Column A and Paste it to Column C


So with that VBA ran, the result should look like this:


Column AColumn BColumn CColumn D
7 Char Description7 Char Descr. Check3 Digits Description3 Digis Descr. Check
Tab Mex
FALSEMEXTRUE
TAB BraFALSEBRATRUE
TAB ECUFALSEECUTRUE
CZE/SVKTRUECZE/SVKTRUE
BIH/HRVTRUEBIH/HRVTRUE
GBR/IRLTRUEGBR/IRLTRUE
PLR PRTFALSEPRTTRUE
PLR CANFALSECANTRUE
HUN/POLTRUEHUN/POLTRUE

<tbody>
</tbody>

I hope I have explained it well enough. Unfortunately, I cannot upload anything from my work PC. But if its requested, I can do it later at home.

THANK YOU VERY MUCH IN ADVANCE.

Kind regards

Ildestino
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Has to be VBA?

Rich (BB code):
Sub MergCel()
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lastrow
If Cells(i, 2) = True Then
Cells(i, 3) = Cells(i, 1) :Cells(i,4) = TRUE
End If
Next i
End Sub

NOTE: You've changed the values in column D but haven't said anything about that in the description of the problem ?
Remove the part in red if you don't want it
 
Last edited:
Upvote 0
Another option
Code:
Sub CopyIfTrue()
   With Range("C2", Range("C" & Rows.Count).End(xlUp))
      .Value = Evaluate(Replace(Replace(Replace("if(@b=TRUE,@a,@)", "@a", .Offset(, -2).Address), "@b", .Offset(, -1).Address), "@", .Address))
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,568
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top