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, [TABLE="width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]7 Char Description[/TD]
[TD]7 Char Descr. Check[/TD]
[TD]3 Digits Description[/TD]
[TD]3 Digis Descr. Check[/TD]
[/TR]
[TR]
[TD]Tab Mex
[/TD]
[TD]FALSE[/TD]
[TD]MEX[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]TAB Bra[/TD]
[TD]FALSE[/TD]
[TD]BRA[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]TAB ECU[/TD]
[TD]FALSE[/TD]
[TD]ECU[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]CZE/SVK[/TD]
[TD]TRUE[/TD]
[TD]/SVK[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]BIH/HRV[/TD]
[TD]TRUE[/TD]
[TD]/HRV[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]GBR/IRL[/TD]
[TD]TRUE[/TD]
[TD]/IRL[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]PLR PRT[/TD]
[TD]FALSE[/TD]
[TD]PRT[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]PLR CAN[/TD]
[TD]FALSE[/TD]
[TD]CAN[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]HUN/POL[/TD]
[TD]TRUE[/TD]
[TD]/POL[/TD]
[TD]FALSE[/TD]
[/TR]
</tbody>[/TABLE]


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:


[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]7 Char Description[/TD]
[TD]7 Char Descr. Check[/TD]
[TD]3 Digits Description[/TD]
[TD]3 Digis Descr. Check[/TD]
[/TR]
[TR]
[TD]Tab Mex
[/TD]
[TD]FALSE[/TD]
[TD]MEX[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]TAB Bra[/TD]
[TD]FALSE[/TD]
[TD]BRA[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]TAB ECU[/TD]
[TD]FALSE[/TD]
[TD]ECU[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]CZE/SVK[/TD]
[TD]TRUE[/TD]
[TD]CZE/SVK[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]BIH/HRV[/TD]
[TD]TRUE[/TD]
[TD]BIH/HRV[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]GBR/IRL[/TD]
[TD]TRUE[/TD]
[TD]GBR/IRL[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]PLR PRT[/TD]
[TD]FALSE[/TD]
[TD]PRT[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]PLR CAN[/TD]
[TD]FALSE[/TD]
[TD]CAN[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]HUN/POL[/TD]
[TD]TRUE[/TD]
[TD]HUN/POL[/TD]
[TD]TRUE[/TD]
[/TR]
</tbody>[/TABLE]

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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,223,227
Messages
6,170,847
Members
452,361
Latest member
d3ad3y3

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