## How to write this formula in VBA

## How to write this formula in VBA

(OP)

I have hit a wall in writing a portion of an Excel 2016 macro...

Haven't figured out how to write VBA for:

In

If F = P, copy F to

If F <> P, copy P to

I have a similar concatenate snippet that works and loops through every row of

I know how to get the results by formula::

1) Insert one col (G)

2) In col G, type & fill-down the formula

=IF((F2=R2),F2,F2 & " / " & R2)

3) Copy & Paste Values from col G to col F

4) Delete col G

Any help would be greatly appreciated!

Haven't figured out how to write VBA for:

In

**ws Extracted1**,**For every row**, compare cell**F**to cell**P**,If F = P, copy F to

**ws Sorted**corresponding row of cell**B**If F <> P, copy P to

**ws Sorted**corresponding row of cell**B**I have a similar concatenate snippet that works and loops through every row of

**ws Extracted1**but it does not require an**IF statement**as I need for the above scenario.I know how to get the results by formula::

1) Insert one col (G)

2) In col G, type & fill-down the formula

=IF((F2=R2),F2,F2 & " / " & R2)

3) Copy & Paste Values from col G to col F

4) Delete col G

Any help would be greatly appreciated!

## RE: How to write this formula in VBA

Don't understand why in the first case you have F, P & B, but then you formula has F, R & G???

1) Using your first case, just enter the formula in the

first data rowof column B of your table inSorted.2) Then double-click the HANDLE (lower right-hand cell corner) to propagate the formula through all data cells of your table.

3) Then select the data in column B, right-click > Copy, right-click > Paste Values.

Turn on you macro recorder and record that sequence.

Post back with your recorded code to clean-up help.

Skip,

_{ Just traded in my OLD subtlety... for a NUance!}"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

## RE: How to write this formula in VBA

Doesn't that requirement mean that the value in column P is ALWAYS the value that will end up in column B?

Skip,

_{ Just traded in my OLD subtlety... for a NUance!}"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

## RE: How to write this formula in VBA