First time coding, first rubber ducking


So I’m an absolute beginner, trying to learn VBA to better understand a macro that I use at work all the time, but the creators are long gone. I wanted to cut my teeth on something simple, adding a new error message to check that the user has used the correct format. I mimicked an existing error message format and could not figure out what I was getting wrong!

I tried all sorts of combinations of formats and methods, but nothing seemed to work. Out of frustration, I came here and started to transcribe the code (I’m coding on a different computer that is off this one’s network).

As I’m transcribing it, it then hit me. ElseIf, you dummy! Tried that, didn’t work. Something was wrong with the formatting?

I forgot the ‘s’ on “cells()”.

For reference, lines 1-5 & 11 were the existing code, 6-9 were mine. The referenced cell used number formatting, so a DD MMM date format would turn into a giant number. The full macro needed the DD to compare against other items.

I’m having way too much fun with this!

submitted by /u/Tanto63
[link] [comments]

Leave a Reply