It seems to me that it will be better for you to take a deep breath (perhaps go for a little walk) and then concentrate.
You seem to like the "Left" option
example : If Left(Range("A1"), 2) = "O.D."
then your code ...
don't use "item" since it is a "reserved term" in VBA
(you see that because it's getting un uppercase automatically)
let's use "cell" instead
I've inserted a messagebox so you can see what happens
open a new workbook
put in some testdata
paul steven jack Sting
select those data
run this macro
Code:
For Each cell In Selection
MsgBox Left(cell, 2)
If Left(cell, 2) = "st" Then cell.Offset(0, 5) = "st"
Next cell
thnak you eric
very much
now normally when i use a for each i use item in selection
what would be the difference if i use item or cell?
againn thanx for ur patients
About "Item" (or "Name", "Time", ...)
click in that word within your code and press F1
the Help will appear on that item
sometimes this specific word is needed by VBA itself, that's why we don't use it
test this:
type: name = "excel"
pressing ENTER it will change in Name = "excel"
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.