Using the left-function

I'm trying to create a simple macro that copys the two first numbers in each cell in a column and printing them in a different column. This is in a excel-document with more than 1 worksheet. I've tried for a while to write the code, but with no prior experience, I have a hard time figuring out what to do. I know the "left()"-function is able to do this, but I don't know how I define which column to draw data from and to which column it will be printed. Any help will be greatly appreciated.


With no prior experience to writing VBA code, I am going to reccommend you stick to the formula method of doing. Honestly, even if you were familiar with VBA, you might still opt to use the formula.

A formula is put into the actual cell you want the value to be copied.

=LEFT(sourceCell, #of characters you want)

This is how it would look:

=LEFT(Sheet1!A1, 2)

Think of it as saying "this cell shall equal the first n characters in cell OO, starting from the left".

Once you are done with your formula, if you don't need it to be binded to the source anymore (if the sourceCell changes, so does the cell with the LEFT formula), you can highlight the cells, Ctrl + C to copy, then right-click and select Paste Special. Then select VALUE and hit OK and now the cells are hard-coded with the value they were showing, as if you typed it yourself.

Once you master using formulas, the next step is VBA. Don't go confusing yourself by jumping into VBA and writing code for ranges, etc. if you aren't comfortable with using =LEFT yet. One step at a time, and you'll be a pro before you know it. :)

Need Your Help

ASP.NET: How to determine account login?

c# visual-studio

Can someone please point me in the right direction as to how to determine if an user is currently logged in?

Find the three letter country code using HTML and Javascript

javascript html ajax geolocation reverse-geocoding

I am trying to find user's location meaning in which country he is browsing. I need to use HTML and Javascript for this. I have seen various posts on stackoverflow on this in which people have sug...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.