VBA Coding Help

ukario

New Member
Joined
Mar 28, 2014
Messages
2
I am trying to create an excel spreadsheet that will be saved into a shared drive within my company. The spreadsheet is made up of 11 columns all which will have information, and a X amount of rows. what i need is a code that will automatically send me the information on a row once it is filled out completely. I am not a skilled coder so i have no idea how to make one for this type of situation. if a button is required instead on a(n) automatic send then that would be fine.

Let me know if there is more information that needs to be provided.
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

ztodd

Board Regular
Joined
Sep 17, 2014
Messages
221
Here is my intro to VBA for you:

The programming language used in creating Excel macros is known as VBA (Visual Basic for Applications).
To open the macro editor / VBA editor, from Excel, press Alt-F11.
The building blocks of a macro are known as functions and procedures. Functions can do all the same things + more than what procedures can do, so I always use functions, unless a procedure is explicity required.

To get to where you can type in or paste in a general function or procedure, click Insert --> Module. To start a function, type the following line:
function myFunction

Then press Enter. It should automatically put () after your function name for you, and create an "End Function" line for you.

If you want or need to use a procedure instead of a function for any reason, instead of typing "function", type "sub"- like this-
sub myProcedure

and press Enter. Now you're ready to start coding in VBA. Now if you ever find any code in an internet search and try it out, you can copy and paste that code into your function or procedure (if it already has a "function ...()" or a "sub ...()" starting line then you don't need to type your own).

To execute a procedure or function, just click anywhere inside that procedure or function and then press F5.


EVENTS

Events are another very important thing to understand- Excel calls certain procedures that are named a certain way whenever certain events are called. Example- if you want certain code to run whenever someone changes something on sheet 1, then put that code inside the Sheet1 module, into a procedure named Worksheet_Change. Your "sub" line starting the procedure has to look like this-

Private Sub Worksheet_Change(ByVal Target As Range)

(Actually it doesn't necessarily have to be private, but you can learn more about that later)
The part inside the parentheses is a declaration of "parameters" that the procedure can use. There's just one parameter here- named Target. The "ByVal" means the parameter is passed "by value"- again, you can learn more about that later- not real important right now. the "As Range" is telling you the data type of the parameter variable- Range. For this procedure, this parameter tells you which cell, or range or cells, was changed. So your code can check what cell it was and/or what value it changed to, and take action based on that. Here's an example of how to do that :

Code:
if target.cells(1,1) <> "" and target.cells(1,2) <> "" and target.cells(1,3) <> "" then 
    msgbox "Columns A, B, and C have been filled in."
end if



Now you can go ahead and try doing an internet search for things like "excel vba send email"- let us know if you have questions about what you find.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,810
Messages
5,525,017
Members
409,615
Latest member
papaluigi94

This Week's Hot Topics

Top