IF and Left

valemarje

New Member
Joined
Apr 20, 2022
Messages
31
Office Version
  1. 2016
Platform
  1. Windows
I currently use the formula

Range("D2").Select
ActiveCell.FormulaR1C1 = _
"=IF(LEFT(RC[-2],5)=""DAVID"",""DAVIDE"","""")))))"

but I would like to be able to put something like this, only I don't know the correct way:

If Range(B2).value (LEFT(RC[-2],5) = "DAVID"
Range("D2").value ="DAVIDE"
else
Range("D2").value =""
end if

Can you help me?
 
on the simple cell I think it works and that is exactly what I wanted so I thank you.

how do i tell it to repeat for each row from B2 to B6000 row for example?
and put the corresponding data from D2 to D6000?
Do you really want to go down to EXACTLY cell 6000, or just to the last populated cell in column B?
Are there any blanks in the middle of your data in column B or not?

What are all the values you want to check column B for (you mentioned "DAVID", "MIS" and "MISS" so far)?
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
values are a lot... I think about 32. not only "DAVID", "MIS" and "MISS"
And I'd like to start at B2 all the way down to the last full field.
The first row is sometimes there after 300 rows sometimes after 5000... so I was thinking of taking the maximum.
 
Upvote 0
values are a lot... I think about 32. not only "DAVID", "MIS" and "MISS"
So what is your intention?
To create 32 separate blocks in your VBA code?
Or do you have list of all the values somewhere, which the corresponding value for each?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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