# Yay - I just did my first bit of VBA!!!



## Patience (Jun 14, 2006)

I am determined to learn and use VBA, and I can proudly announce that I just wrote, understood and edited my own firt bit!!!     I am feeling very proud of myself.

Onwards and upwards.  :-> 

I just wanted to share that with you all.


----------



## Von Pookie (Jun 14, 2006)

So what was the code?


----------



## Patience (Jun 14, 2006)

Dammit - it was really. Really. Simple. But it is all my own work, and we have to start somewhere, right?

And it will be genuinely useful for me.


```
Sub FormatAsCurrency()
'
' FormatAsCurrency Macro
' Macro recorded 14/06/2006 by bryony
'

'
    Selection.NumberFormat = "_(£* #,##0_);[Red]_(£* - #,##0;_(£* 0)"
End Sub
```


----------



## erik.van.geit (Jun 14, 2006)

<font face="Courier New" size="+1" color="blue" style="background: url(http://www.balloondoggies.com/vonpookie/misc/sparkle.gif)">BRAVO !!!!</font>


----------



## Smitty (Jun 14, 2006)

Good job!

Now if you assign a shortcut key to it it'll be even easier to use. 

Smitty


----------



## Patience (Jun 15, 2006)

> Now if you assign a shortcut key to it it'll be even easier to use.



I have done better than that (I think.) I have created a Custom Menu so I don't need to worry about overwriting exsisting short cuts. However, I can now get to it by pressing Alt+M+C. Which I reckon is pretty cool.

Of course you know now that I will be in the Excel Questions forum often begging for help! But I promise I will always try to work things out for myself first.

Since posting that I recorded a couple more macros and adapted  them in the VBE - which are slightly more complicated. Obe I am having a little trouble with at the mo, but I aim to have it sorted today.

I love this stuff.


----------



## PaddyD (Jun 15, 2006)

"Since posting that I recorded a couple more macros and adapted them in the VBE - which are slightly more complicated."

Perhaps:

http://www.tushar-mehta.com/excel/vba/beyond_the_macro_recorder/index.htm

will be useful to you.  
Keep it up


----------



## Patience (Jun 15, 2006)

Thank you. I am just reading through it now, and it is. It is addressing one problem I have already. 

So far all my successes have been essetially adapted/bastardised versions of recorded Macros, but I am finding that a useful way to learn what the code means. It seems really weird to be basically learning a new language. Its like I have learned the 'language of Excel' (fumctions/arguments etc) and now I am starting from scratch again.


----------



## litrelord (Jun 15, 2006)

Well, keep at it mate.  It's well worth the time taken to work out what's going on with the code and moving into writing your own code from scratch.  Be careful if you're the only person at work who knows much about VBA.  If that's you then be prepared to be "The Excel Guy" (that's not necessarily a bad thing of course £££££££££££)

Nick


----------



## TrippyTom (Jun 15, 2006)

This is very refreshing to see someone so excited about learning it themselves.  WAY TO GO!


----------



## doco (Jun 17, 2006)

I can see it all now - a couple years down the road when he is on a development team and the team leader calls a meeting to tell them: "Alright!  You people start coding and I'll go see what they want.."

Wonder bout the xxxcitement then?


----------



## Patience (Jul 5, 2006)

Hey all, I am still excited! But it is dead hard. Once i get properly over the first hurdle I think I will be fine. I will be the only person who knows it/sorta knows it, but then I am the only person here who understands what VLOOKUP is. 

Onwards and upwards!


----------



## SydneyGeek (Jul 11, 2006)

Getting a handle on the language can definitely be a hassle. 

Like you said, the recorder is a good place to start -- especially once you know how to get rid of the crap afterwards (record a macro to change page orientation, and see what I mean). 

Still, the best way to learn is getting your hands dirty -- up to the armpits!

Also, check out the thousands of examples on this site. There's some really cool approaches to solving problems that you can likely adapt, then pick apart to see how they worked. 

Good luck!
Denis


----------



## Greg Truby (Jul 12, 2006)

Congratulations on getting your feet wet in VBA.  As you get some more experience you'll also begin to get a better feel for when to use VBA and when not to.  For example - the code you posted?  You could also have simply defined a new style and if you wanted customize your Formatting (or some other) toolbar by adding the _Style_ listbox control to it.  One of the things I seem to be seeing more frequently on the questions board is posters saying "I need a macro to..." when in fact they don't really need a macro at all. 

Again, I don't mean to come across as discouraging!  Quite the opposite in fact!  You have taken the first steps into a bigger world.  Once you start using VBA your possibilities will expand phenominally.


----------



## Patience (Jul 13, 2006)

> Again, I don't mean to come across as discouraging!



Not at all! Thank you for your advice. I realise that what I did was not really macro worthy, but it was about the simplest thing I could think of that I would use.


----------



## Zack Barresse (Jul 13, 2006)

Congratulations Patience!  That is quite nice to hear your excitement!  Keep it up and you'll be learning more than you ever knew.  :D


----------

