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.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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.
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,539
Members
449,316
Latest member
sravya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top