I am a Desert, baby.

Last Updated

December 05, 2006 07:30 PM

Recent Entries

Categories

Search Entries






Creative Commons License
This weblog is licensed under a Creative Commons License.


Syndicate this site (XML)

Powered by Movable Type 3.2
Excel Macro to VBA Code

Fuck. Fuck fuck fuckity fuck.

I spent three god damned hours trying to convert an old Excel macro in to Gods Damned VBA. What to know what thwarted me? One stupid command. Gods, I felt like a fucking moron by the time I actually finished struggling with the bastard. Mostly I felt like a fucking sackless twat (or I suppose, in my case, since I am already sackless; a titless twat) because I forgot about the Gods Damned Record command.

Anyway, this is the line I couldn't convert:

Excel version:

=TEXT.TO.COLUMNS($E$4,1,1,FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, "|", {1,9;2,1;3,1;4,1;5,1;6,1;7,1;8,1;9,1})

Yeah, aren't I a dumbass? I fully admit I can't code for shit. I'm horrible at it. I am sitting here with two VBA books open, one Excel Book open and one printed out ghetto Microsoft command conversion book open. I am a shitty coder. I can do second order differential equations and quantum field theory in my head, but I can't convert one line of bloody code from Excel to VBA.

After struggling with it for about an hour, I finally realized I could use the record command. I knew the basis of what command I had to convert this into, but not the proper syntax. (I'm bad with coding... bad bad bad.) So, this is what the line turned into in VBA:

VBA version:

Selection.TextToColumns Destination:=Range("E4"), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1)), TrailingMinusNumbers:=True

Yup, you guessed it. Arrays. That's what fucked me and why it wouldn't work. I should have thought of it, but, like I said, I can't code for shit.

Posted by Utopia at October 26, 2005 09:59 AM

Comments


I still love hearing "sackless twat".

VB is evil and bloated. You will never convince me otherwise. Best of luck.

Posted by: Mango at October 26, 2005 10:51 AM



I was never much of a VBA fan myself, but this is largely due to thee factors:

As a general thing, I don't program for Windows (this is looking like its going to change as work is directing me to C#)

I prefer languages that let me mess about at a bit level.

The only time I ever had to use VBA, was when I spent 6 months debugging/rewriting an Access application that I was not permitted to simply rewrite from scratch in SQL and something else. Every single line there could have made thedailywtf.com (which is usually entertaining if you're frustrated, just to see how bad it is out there). One of those programs where you could see that he was trying different mistakes until he made the right one.

But if VBA suits the purpose, theres no reason not to use it.

Posted by: Meathe at October 27, 2005 12:43 PM



I am only using it because I have to to rewrite these macros into Excel spreadsheets. I hate it. It is rather unintuitive and abckwards in my mind. I much prefer Fortran or Pascal (which I can actually code in as opposed to C++).

But, I have at least finished my code and it seems to work the way I want it to. It's far longer than it should be, but I'm not going to streamline it or take out my snarky comments. If in the future someone in the company wants to mess with the program, they can deal with my attitude.

Posted by: Utopia at October 27, 2005 12:59 PM


Post a comment




Remember Me?

(you may use HTML tags for style)