Convert simple formulas into vba code for range cells

asar90

New Member
Joined
Sep 8, 2013
Messages
4
Hi friends,
I have to convert formula into vba code for a range cell
for Eg:formula for a single cell Say C2 = LEFT(L2,FIND(" ",L2,1)-1);

I want to put this formula into vba code for range cells say C2:C

I know this Is Simple but I'm very new to this!

Any Help

Thanks in Advance......
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
18,205
Office Version
2013
Platform
Windows
Change the range reference in "C" to suit

Code:
Range("C2:C100").Formula = "=LEFT(L2,FIND("""",L2,1)-1)"
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
18,205
Office Version
2013
Platform
Windows
Pleasure....(y)

If you wanted to make it dynamic, try

Code:
sub MM1
dim lr as long
lr = cells(rows.count,"L").end(xlup).row
Range("C2:C" & lr).Formula = "=LEFT(L2,FIND("""",L2,1)-1)"
end sub
 

Forum statistics

Threads
1,082,632
Messages
5,366,678
Members
400,913
Latest member
SarahMS1

Some videos you may like

This Week's Hot Topics

Top