GitXplorerGitXplorer
m

vba-methods

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
fc510cbef91e589096b1a8055568010901197f25

Add files via upload

mmonkeywithacupcake committed 5 years ago
Verified
f1429d3c8286e33bd4cbb8c65049dcf6ca0e1d24

Add files via upload

mmonkeywithacupcake committed 5 years ago
Verified
9256e20870442bd5e2154a3ad2ead3fdea89567d

Create README.md

mmonkeywithacupcake committed 5 years ago
Verified
6836922c16250f8a37177d399af115442c67a454

Add files via upload

mmonkeywithacupcake committed 5 years ago
Verified
3adce247d9f2a53896411281ee5cc5510b19bb63

Create README.md

mmonkeywithacupcake committed 5 years ago
Verified
d6a636525ff7bfa3491d6a38026cfb3202dde817

Delete Sample

mmonkeywithacupcake committed 5 years ago

README

The README file for this repository.

vba-methods

Code size

A collection of Subs and Functions to do things in Excel VBA For Microsoft Office 16.

Subs and Functions are saved as .vba files to ensure the repository language is correct. What is the difference? Generally, a Sub does a thing and a Function returns a thing.

How to Contribute

PRs and Issues welcome. Use Issues for questions. Use PRs for new functions. Each file is a function Please remember that beginners will use this code. Add comments as needed.

Conventions

We will try to use VB Coding Standards for consistency. The big picture means to

  • Use verb starts and camelCase for sub and function names. Like "getMoreFood()" and "returnLastCupcake()"
  • Use NounDescripter for variable names.
  • there are a whole bunch of others

How to Use

You can copy and paste functions directly into your Visual Basic Windows.

Generic use of a Sub or Function

Let's assume that you want to incorporate the Sub printa(), Sub printStr(myStr), and Function getNextInt(myInt) in another Sub. Of course, this is a contrived example.

First, save your project with the new subs and/or functions in a Module

Sub printa()
   Debug.Print("a") 'prints a in the Immediate Window
End Sub
Sub printStr(myStr As String)
   Debug.Print(myStr) 'prints the passed String in the Immediate Window
End Sub

Function getNextInt(myInt As Integer)
  getNextInt = myInt + 1 ' returns the next Integer
End Function

Then, you can call it in your other Sub

Sub doOtherSub()
   Call printa
   Call printStr("I like Cupcakes")
   
   Debug.Print(getNextInt(4)) ' prints 5
   
   'You can also Dim and use variables
   Dim smyStrVar As String, imyIntVar As Integer
   smyStrVar = "Do you like cupcakes?"
   imyIntVar = 12
   
   Call printStr(smyStrVar)
   Debug.Print(getNextInt(imyIntVar)) 'prints 13
   
   ' You can write to variables with functions
   Dim imyNewInt As Integer
   imyNewInt = getNextInti(myIntVar) 'now, imyNewInt is 13
   
End Sub