1182017 Jala Excel Macro (VBA) Tips for Boginnars
earch Gal
suuoareee wessre [@) of € gf
(OF YOUR OWN ON pp eis daa ST
Angelfire€ | ES !
anion
(last update 30/6/2010)
‘email (without spaces): julian.excel @ gmail.com or
julian7_s. @ yahoo.com
Follow @IulianExcelTins
Index listing ABCD EEG.
LIKLMNOBORS
UVWXYZ end
Excel Macros (VBA) tips for beginners. I do not use macros that have too many lines of codes as this may confuse beginers. I remembered
‘when I started learning macro programming and going to sites by Chip Pearson & John Walkenbach and started secing stars instead of
‘VBI, Simplified macros are used for easy understanding for people like YOU and ME. By the way by, 1am trained as an Accountant and
‘not a programmer. I hope the this site gets you started in Macro Programming & Good Luck.
NOTE : Run the macros at your own risk. Macros cannot be un-done. Therefore always save your workbook before running any macros.
Auto Run 26/12/2000) aches
‘Making your macros run automatically when opening your workbook. You can either use the Auto Open method or the Workbook Open method.
‘These macros will display the message "Hello" when you open the workbook,
Sob Asto_Opend
Msghor illo"
ne Sob
This code would be located in the module. However if you use the second method, the code must be in the workbook (double click "This
Workbook" inthe explorer window). Click on the drop down list (that says General) and select Workbook. Click on the drop down list (tht says
declarations) and select Open,
Private Sub Workbook Open)
Msgbox "ell"
Active Cell (52002) actsoso0)
‘An active cell is the current cell that is selected, Ths term is used in many macros. This can be used as a marker, A good example is when you need
to move from your current cll. Refer fo Moving your cursor macro
Adding Items to a combobox (15/2002) acto.
“To add a combobox refer to User Form, To populate a combobox or a listbox is the same, You could ada from the code or even from a range of
ces in your spreadsheet To add from the code, just add tis line to your code
Combobox! Assen "oduct A”
CCombotou!-Addhem "Product 8°
Lear IT Word
At Home
‘Counting Rows & Columns & Sheets (27/0/2001} ack 0
When you have selected a range, its sometimes useful to know how many rows or columns you have selected as this information can be used in
your macros (for eg when you have reached the end, you will know itis ime to stop the macros, This macro wil do the tick,
Sub Count
‘ayCoust = Selection Rows Couat ‘Change Rows Couns to court columas
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him wn1182017 Jala Excel Macro (VBA) Tips for Boginnars
Mogiiox myCout
re Sob
method.
‘The next macto counts the number of sheets instead. Refer to Protecting all sheets macro which uses this
Sub Counap
‘myCount~ Application Sheets Count
Megdiox myCount
(Carriage Return (10/1/2002) hacks.
‘Sometimes you may want to puta line of text on the next row and not let it continue on the first row. See this example in a message box.
Sub TwoLinex
fe 1" & YOCHLER "Line 2"
(Close All Files (292009) a
‘Sometimes you may want to close all files without saving, Doing it manually is a hassle with the question "Do you wanna save?"
Sub Closeallo
Application DisplayAlens alse
imyFatal = Workbooks Count
Fori= 1 TomyToua
“activeWokbook Close
Next
End Sub
Copying A Range 5/1/2002) fbacktotan)
Copy data from a specific range ean be done with this macro, Here data is copied from the curent sheet to the activecell (Refer to Active Cell)
Sub CopyRangsd,
Range*AI:A3"} Copy Destination ~ActiveCell
End Sub
‘To copy from a range in another shect (eg Shect3) to the active cell you need to change the code to;
Shecisheet") Renge’AI-AS") Copy Detnation: Active
Counter (17222002) dacteoton)
‘To use # counter in your macro, just assign any cell to retain the value. In this example the esll AL is chosen. Each time the macro is run, it adds the
value 1 to the cell Al
Sub Coustp
rmycount Rangel") +1
Range") —myeoust,
Eresob
Current Date 24122001) backeo ton)
Its a good idea to insert the current date when you save the file so that you can tel i i's the latest version. Of course this is shown under fle
properties but how many people know where to find it? You could also pu the curent date in the footer of your printout I is ideal if the date does
not change unless the ile is saved. You can use this code. (On the drop down list that says declaration, select before save and you will see the Ist
line of code shown below - more details refer to Auto Run macro)
Private Sub Workbook, BefreSaveByVil SaveAsUI As Boolean, Cancel As Boolean)
RangeAI")=Now — Selectany cll you want
eso
Current Cell Content (2412/2001) acto oe
‘Sometimes we need to know what the cell contains ie dates, text or formulas before taking a course of action, In this example a message box is
displayed. Replace this with a macro should you require another course of action,
Sub Contethko
ApplicaionsTeat(ActiveCell) Tae Thea
Megiion"Text™ —Yeplsce thie ine with yourmaera
Ese
MsgBox "Blank cell” eplce isin with your macro
Ende
IF AciveCetseFormula Thea
MsgBox formula” eplieethisine with your macro
Ele
Ene
{sDate(ActiveCall.Vlue)= ive Thea
Mrgiiox'dale” replace thisline wth your macro
Else
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him anJala Excel Macro (VBA) Tips for Boginnars
Current Cell Address 80/62010] _@ackio so
‘To get the current cell address (or current range) to perhaps incorporate into your formula, you could use the following code.
Sub Myaddes
Meglio AciveCs Address “whole cll rfrence with he pskyS sens
Magiox AniveCel AddiesRowAbyoute- Fuse columaAbsolue:- Fale) ‘without the signs, you may choose a omit either one Row / Colum absolute
ne Sob
Current Cell Position (10/2002) askuasand
‘Sometimes we need to know the curent cell position, This would do the trek.
Sub MyPositiong
smyRow = ActveCell Row
tmyCat~ Actives Colm
Mighox myRow "> & 2yCol
ne Sob
Learn IT
&t Home Power Point
Deleting Empty Rows (27/10:2008) hack vo)
‘To delete empty rows in a selected range we can use the following macro. The macro here uses the For Next Loop. First the macro counts the rows
ina selected range to determine the when the macro should stop. The For Next statement acts as a counter.
Sub Delmpty Row)
Rng ~Seection Rowe Count
AativaCell et 0) Selest
‘enliston SereenUpaa
“Then "You can eplace with Oto delet rows wih he vale ze
Selection EntieRow ele
Ele
AativeCelL Ober, 0) Select
Eadie
Newt
Application SsccaUpdaing = Tue
Ee Sob
‘The statement "Application SereentUpdating = False” prevents the sereen ftom updating fo ensure the macro runs faster and the sereen will not
flicker, Don't forget to set it back to "True",
Deleting Range Names (15032002) dacktzsaed
‘To delete all the range names in your workbook, this macro wil do the trick.
Sub Deets
For Eacn NameX In Names
Active Wostbook Nunes Name Name) Delete
NextNamexe
End Sub
Duplicates (Highlight duplicates in Bold Red) 27/1001) hack oo
‘There are times you need to highlight duplicate data in your worksheet, This macro does the trick.
Sub Dupskedo
Application SsrenUpdating~ False
Bag ~ Selection Rost Couat
Foti“ RnpTo 1 Sep
imyCheek = ActiveC
DativeCellOfet 8) Seest
For)=1Toi
Selection Fort Bold = Tue
Ene
AativeCell Ot, 0) Select
Next
AativeCell Ot, O.Sleet,
Application SeceaUpdating = Tue
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him an1182017 Jala Excel Macro (VBA) Tips for Boginnars
Emailing Workbook (21222001) ack ston
‘To email your current workbook the following code.
Sb Fit
‘Active Workbook SendMbil ipa
usa yahoo com!
EDIT macros (0162003) astto tol
Refer to Text Manipalation.
Errors in macros (122002) dactio.op)
Ever had a macro running perfectly one day and the next day errors keep on popping up even though you never made changes to that macro? This is
no fault of yours, Duc tothe excel VBA design, macro files get badly fragmented duc to heavy editing of macros, insertion of modules & userforms.
‘What you need to do is copy your macros else where, delet the macros, save the file without macros. Open the file again and import the macros and
save it once more with the macros. You macros wil run properly until it gts fragmented again ata later stage.
Error Trapping si\2002) backtaae)
“Trapping errors are important as users can do marvelous things to mess up you macros. Here you can use cither of these 2 statements,
“ln Bor Gote Ener
Enoctap
mor code (what do fer an ema)
‘The fit statement will llow the macro lo continue the next line of code upon biting aa error bu the second statement will run an alternative code
should there be an extor,
Learn IT
&t Home Power Point
Excel Funetions 62/2002) guctosenh
Using Excel functions in VBA is almost the same as using them in a spreadsheet. For example to round an amount to 2 decimal places in @
spreadsheet would be;
round 2345.2),
In VBA you would ned to use the term Application followed by the function i;
‘AsveCell~ Appliationound( etveCel,2)
For more examples see Rounding Numbers
Expiry Dates for Workbook / Macro (0/1/2002) dackio.
‘See Security in Exec),
For, Next Loop (5/1/2002) astsosap)
‘See Deleting Empty Rows or Protect All Sheets. A point to note is, try not to use the For, Next loop because this method is very slow unless of
‘course you don't know how to write your macro another way,
Flickering Sereem (29/10/2001) sda)
‘Sometimes when you run & macro the sereen flickers a lot due tothe screen updating ise. Ths slows the macto done especially when the macro
hnas.alot of work to do, You need to inelude the statement as shown below,
‘Also see Deleting Empty Rows.
Application SereeaUp
You need to set the sereen updating back fo true atthe end of the macro,
Funetions (5112002) backso op)
Creating funetion is useful as complicated formulas can be made easier in code than in a spread sheet, Formulas can be protected so that users
‘cannot see or modify them, The example I use will calculate tax using the Select Case Statement, Her the seuaso,
int $2500 stan fee
[Next 2500 ie table at 5%
‘Anything shove $5000 is taxable a 10%.
Incell Al type Income ad is ell I type in yourincome in numbers say $20000,
‘eel A2 pe Tux payable and in cell B2 ype “ax B)
atthe fllowing code in amodsle. Ths tex payable her wou be 1625,
Public Fanctionelincome As Single)
Selot Cas income
0
incone =2500) 0.05
Cae Else
tax fincome-S000)* 01
End Select,
Fe Fonction
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him an1182017 Jala Excel Macro (VBA) Tips for Boginnars
Goto (a range) (27102001) back 00
‘To specify a macro to go toa specific range you can use the Goto method, Here I have already named a range in my worksheet called "Sales". You
may also use an alternative method ie the Range select method, Naming a range in excel is recommended rather than specifying an absolute cell
reference.
Sub Gates)
Applicaton Goto Reeence'Sales" OR RangetSses")Selet
End Sub
Going to the 1st Sheet [27/1012001) eckson
‘You cn select the frst sheet ofthe workbook without knowing the name ofthe sheet by referring to it by the index.
Sub Fintsheet)
Specs) Selest
End Sub
GoTo Sheet (15/05:2005) Backes 0
‘Sometimes we have many sheets or sheets with long names & we cannot view them all. You can select which sheet to goto by using this macro,
Sub Go2shee
rmyShte~ AstiveWorkbook Shots Count
Fork =1 Teaystis
ImpList=mytit i & "=" & ActiveWorkhook Sheets) Name "*& vbCr
Nextt
Dim my Sht AaSingle
aySit~InputBoxSelest shoe gota." & VBCF& VOCr mist)
Shecsiny Sb sSlect,
End Sub
Hiding Sheets 27/102001) ackio tan)
‘To hide your worksheet from users You can use the following code,
Sub Hidesteero
Sheet Visible" xisheetVe iden
End Sub
If you hide your sheets this way, users will not be able to unhide them using the menus. Only using VB codes will be able to display the sheets
again
Hiding Excel (59°2002} acto on
‘You ean hid the Excel application with ths macro. Ths disables the user from using the excel menus. Don't forget to set it back to visible
Sub Hideto
Application Vible~ False
End Sub
Learn IT
At Home Power Point
Input Box 27/102001)—dachuosand
‘When you need to get input from users, you can use input boxes. This macro will ask forthe users name and will display a message "Hello" plus the
user's name,
Sob Gating
DinMyloput "Thisline ofcode is ptonal
Myinpst = InpstBoxt Ester your name)
Migiox (Hello ")& Mylnput
Inserting Rows(s!1/2002) asta
“To insert rows required by a user is easy. Here the input box is used so that a user ean define the numberof rows required
Sab nso
Din ee
Rng ~inputflon(Enter number of ows eave")
‘ange ActiveCelL Oe 0), Activecell Ofsetfeg.- 1, 0))Seleet
Ene Sub
‘ere the macro uses the range technique where a range is frst selected and then subsequently rows are inserted,
IF, Then Statement 27110200] backs oo
‘See Protect All Sheets
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him sit1182017 Jala Excel Macro (VBA) Tips for Boginnars
Joining Text Together (10132003) ducks nh
‘There are times where we import text file into Excel an we gettext that are separated, I received an email asking how put these text together. Select
across your cells frst and nan this macro,
Sub Joint
ray Cal Seleston Colma Count
Fori=1 TemyCel
AetiveCell= AtiveeIL OMe, 0) & ActiveCell Of)
‘ativeCell Of)
Newt
End Sub
Killing Files [1/122001) backto ons
Killing or deleting files is easy. However the files must not be in used,
sub Kllteg
DimMyFle As Sting This inc ofcod is options)
‘On Er Resa Next Oe iting ewes code resumes next code
IMF
Wildcards can be use, Replace the fle name with * (use with caution!
Killing The Current File .22002) backio op)
Killing the current file you need to change i's stats to read only.
Sub Killed
Application Display Alera
‘ThisWiorkbook ChangeFifeAccess xIReadOnly
Kil ThiWockbook FullNeme
Thisinhook Clow Fake
End Sub
Lower Case 27/0/2001) duck 1a
‘To change text ina selected range to lower ease use this code.
Sub Lowercase)
Dimeell As Range
For Each cel Ie Selection Celt
Weo HasFormsla~ Fale Then
cell LCastell)
Last Available Row [25/52009) backup)
‘Many users need to know the next available row to input data, Ths code locates the next available row in column A
Sub LastRow 0
ange'a63536") End¢ulUp) OPS! 0)Selet
Learn IT
&t Home Power Point
Message Box (17122002) hack io on
‘When you need to communicate with users, you can use message boxes. This macro will display a message "This macro is created by Julian". The
‘Message Box appearance ean be customised to show whether itis Information, Critical Messages. Here the icon in the message box would be
different. The buttons can also be eustomise to show extra Yes, No, Ok butions. (Refer to vbYesNo macro). This macro will show you 3 different
styles
Sub MyMessageo
MsgBox "Thi co icreated by Julian”
Meglio "The icon ie diferent ebinmaion
Migiox "The op tie i difaca, voExelamaion, “Julia pst
ne Sob
‘Modeless Forms (10/11/2002) hashiasap)
‘Sometimes you want to allow users to be able to switch between your form and your spreadsheet by clicking on either one, All you need tod is set
the form property of Show Modal to False or you can ty this, However this is only for Excel 2000 & above.
Sab myFornd
Userfomahow vbModelee
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him an1182017 Jala Excel Macro (VBA) Tips for Boginnars
‘Moving your cursor [27/102001) —_gackwosan)
‘Sometimes you need to move your cursor around your worksheet to re-postion it before running the next step of a macro. The movement here uses
the row, column position method. Also see (Visible Rows)
Sub Down
AetiveCelL Ofer, 0) Select
End Sub
Sub 99
ActiveCelL Ober, 0)Selet
Ene Sob
Sub Rigo
AativeC lL Oe, 1) Select
End Sub
Sub Leto
AativeCelL Oe) Selet
End Sub
Protecting / Unprotecting a sheet (27/10/2001) guackeap
‘The macros below will protectnprotect the current worksheet witha password.
Sub Poecthest)
DimPassword"Thislin ofcode isoptonal
ActveShos ret Password, Te, Ti, Te
End Sub
Sab UnProtetsheet
Pasovord "1234"
AetiveSheetUnprtet Password
End Sub
all sheets 27/0/2001) hack vo
‘To protect all the sheets this macro uses all the methods contained in this page (see counting shee). The If Then statement is also used here. This
tests for 9 condition and if the condition is TRUE, then the macro continuous the next line of cade. In ths ease it will END the macro, Ifthe
condition is NOT TRUE, then it will goto the following line which in this case is to select the next sheet. You will also notice the For, Next
statement is also used. This aeis as @ counter to tell the macro how many loops to run. In this ease if there are 3 sheets, the macro will run 3 times
protecting all he 3 sheets,
so peso
Dimmycoust” “Tisie ocodeisoponal
fycoust=Agpiaion het oun
Secu otto atte
End
ne
[AdtiveSbeet Next Seest
Neti
End Sub
Learn IT
At Home Power Point
Protecting your VB code (10132002) astuasoo!
‘To protect your VB code ftom being seen by others, all you need to do is go to the project explorer, point at your projet and right click om it. Select
VBA project properties, click on the protection tab and check the Lock project for viewing and key your password, Thats it
Random numbers (2/0/2001) uct too
For macros to generate random numbers, the code is takes this format - Int ((upperbound - lowerbound +1) * Rnd + lowerbound). Where the
Upperbound is the largest number random number to be generated and Lowerbound isthe lowest,
Sub Randomo0)
Randomize
MyNomer=n(9 14 1)* Rnd +1)
Migiox (Tevandom number is") & (MyNumbes)
ne Sob
n this case the random numbers that will be generate is between I and 49.
Range Names[392002) ackio ton
Assigning range names to a range of eels.
Sub Raga
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him mm1182017 Jala Excel Macro (VBA) Tips for Boginnars
nd Sub
Resizing a Range 392002) bactto on
Resizing a range is simple, You can apply this to inserting rows & columns or to expand a selected range. This macro resizes the range to 7 rows by
7 columns
Sub Resizing
Selection Resize.) Selest
End Sub
Rounding Numbers 82/2002) __gusck 1a)
“ere I will show how to perform different types of rounding. Key in 12345 in any active cell and run the following code.
Sub Round
‘AetiveCell~ Application round(ActiveCell. 3)
End Sub
‘This code round tothe nearest 1000 thus giving the value 12000.
ActveCell = Alison Cling(AstveC, 1000)
Replace with his line of ede an wil ound up the nex 1000 ie 15000
‘AciveCall» Application FloonactiveCl, 1000)
Replace wth hse of ede nt wl mend down tthe net 1000 12000,
Running A Sub Routine 5/2002) ashiasap)
‘To nun another macro from within a macro you need to use the Call statement.
Sub Macro
Maghox Tass Mactol")
Call aod "Thiceall for Maem? to 0
End Sub
Learn IT
&t Home Power Point
Saving a file (2372009) uch
‘There are times you may want a macro fo save a file eutomaticlly after running a macro, The seeond macto will save the file with name called
“"MyFile’, You may specify the path if you need to, The last macro saves all opened workbooks.
Sub save)
AativeWorkbook Swe
ne Sob
Sub Savetame)
Active Workbook Saved Fileame"C\MyFile
Sub Savealio
mye ~ActveWoekbook Name
"ActiveWokbook Save
‘AcsiveWindow Aviva
Do While myFile <> ActveWoskbook Name
“AcivNindow Activate
End Sub
Security in Exeel)22002) backs
Level 1 - To protect your excel files, there area few steps required to make it more difficult for other users to by pass security, To prevent changes
‘made fo the worksheet, you need to protect your worksheet. See protecting sheets. To prevent sheets from being renamed, moved ot deleted, protect
the workbook. However protection of worksheets and workbook ean easily be hacked using macros as shown by an Excel developer. I believe the
next level of protection is protecting your macros. To protect your macros, point at your project inthe explorer window, rightclick on it and select
\VBA project propertis, click on the Protection tab, check on Lock Project for Viewing and next key in your password and you're dane, Now the
project cannot be viewed or amended
Level 2 - The next step is to force the user to enable your macro when opening your file. The best way is (o use a macro to hide the important sheets
(Gee Hiding sheets) when saving your file. Upon opening the file, a macro will be used fo unhide these sheets Ifthe user disables the macros when
‘opening the worksheet, they will not be able to view your worksheet unless they allow the macro to run
evel - The final step isto put an expiry date for your worksheet or your macro, However ths has @ draw back asthe user may change the system
date of the computer to by pass the step. Altematively you can use a counter (Refer Counter Macro) to allow a fixed number of access to your
‘worksheet or macro, Here you need to save the counter value each time the file or macro is used. Upon reaching the defined limit, disable the macro
(oF disable the acess of your worksheet,
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him an1182017 Jala Excel Macro (VBA) Tips for Boginnars
The steps mentioned above are not 100% fool proof. But it will keep normal users out but not hackers and crackers. Here I will not supply the code
as this canbe lengthy and may be difficult to understand bu I believe these steps may be useful to some of you out there
Select Case Statement (91/1/2002) ankioaph
‘This is a useful statement to use when you have many conditions. Too many IFs in your code will only make you more confuse. See Functions
Sentence Case (06/2005) aka tan
‘To change text in a selected range to sentence case use this cade. This code was supplied by Simon Huggins. He did a fine job of making the code
‘work for both earlier & current versions of Excel. Thanks for the contribution,
sub Senteneecased
s=eellNaue
Pori=1ToLenls)
eh Mii
Selest Cae ch
Stat ~ Tre
Caer
Stat = Trae
Cae Toe
Stat Then en = Canc Stat = Fae
Case"a" To"
{Stan Thon Sn Fale Ele ch Lash)
End Sle
Midi, 1) ch
Ne
cell Values
Next
End Sub
Select Data Range 0/2006) baccotond
‘This is a useful when you need to select the whole range of data to copy to another sheet (especialy a large range).
Sub SeAMDatag
‘Agliation SeeenUpénting ~Flse
Dim syLastow As Lone
DimmyLascalum Astone
Rangear select
mmyLasiRow~ Cells Find (Al). alByRows,xIPrevious) Rw
smyLasColumn = CellsFind(™, At} xByColuny,xPrviows} Colum
yLasCell = CelsayLastRow myLesiColuma} Ades
myRange = "al: plate
‘Application SeeenUpdating = Tue
[engetms Range) Select
Ene sob
Learn IT
&t Home Power Point
‘Text Manipulation (30'!2003] duces
received many queties rogarding text manipulation, Here are some useful text functions which you could use to EDIT your text.
Sub mya
Magiox LelCabed"2) Displays? chute fom Left
MsgBox Righiabea,2) Displays? characters om Right
MigBoxLenCabed) Displays ashe of chances
ne Sob
‘Text Box Caleulations (In user forms) 24/12/2006) acta
‘To perform calculations using text boxes in user forms, you will need to validate the data frst, otherwise you will be in for surprises. Assuming you
‘want to add two values in 2 separate textbox and assign the answer to another,
Textbox] “Waltenhon2}Waltenboxt)
Timer (12/2002) gactotaph
‘To create a macto to measure time before executing the next line of code use this simple code,
Sob simer)
Agtlistion Nat Now ~ TineVilue'0000:10")
Mepiiox (10 bs elaspes")
End Sub
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him an1182017 Jala Excel Macro (VBA) Tips for Boginnars
‘Title Case 271102001) at toto
‘To change text ina selected range to ttle case use this code,
Sub TleCad)
Dimecll Ar Range
fest asFompla = Fale Then
ccll= Applicaton Ppercell)
nef
New
ne Sob
‘Top ofthe screen (10/1172002) duck,
‘To make the acivecell be atthe top of the sereen & tothe left on the sereen try this.
Sub Tope
AativeCell Select,
With ActiveWindow
ScollColurn - AciveCell Coluae,
Upper Case (7/102001) dace ton)
To change text in a selected range to upper ease use this code
Sub Uppercaseo
Dim ell As Range
esl TisFormls
User Forms (63/2005) hk wo
‘Adding user forms in your macro is simple, With user forms you cas ereate GUIs (Graphical User Interface) for user who do not have much excel
‘knowledge and make you excel programs more professional looking. Go to your Visual Basic Editor window & click on Inset, select user form and
4 user for will appear along with the toolbox. Now you can add labels, butions, text boxes and many more items, The property window will allow
‘you to customise your user form. To display your user Form use these codes
‘StseFonmt show — to load form
Loading User forms with MultiPage (65/2005) acta tan)
‘To select a page in a Multipage object is fairly simple, Just remember the page 1 has e value of 0, page 2a value of 1 and so forth, To load a forma
with a specie page in mind, try using these codes,
Sub poner,
‘serFonal Show ‘his displays the wer fom aferpage 2 has ben se
End Sub
YbYesNo 1722002) ashioap)
‘There are times you may want users to click Yes or No, Just insert ths line of code, Here the Select Case statement is used,
{YesNo = MspBox("This macro wil ..Do you want continue, vBYeENo = VOC
Select Case YrNo
Cae vbYer
"ase your code her ies licked
Cave
"ase your code her ifNo i licked
Visible Rows (selecting) (211272006) actsaop),
The normal way of selecting the next row cannot be used where there are hidden rows or filtered data, To sclect the next visible row ina filtered list
‘we test each row until we find the next visible row
Sub NextVisileRow
ActiveCel OMe O}Seest
Do While AciveC4lEntieRow Hidden = Te
ActiveCal Of, O}Seest
Loop,
Ene Soh
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him sanJala Excel Macro (VBA) Tips for Boginnars
do gets of ema fom al over the world saying that hss a grease for beginners. Truly this encouraging & I THANK YOU ALL for you support. Plese note
some time, Also note that Id at provide the fll source codes but wl ty to plat you inthe right direction. Once again a big Thank You fr visiting my ste
lian's Excel Tips
Julian's Excel Solutions
Link to other Exec! Developers
GOOGLE Group on Excel Programming
Microsoft Office Training
lin today's highly competitive job market, success will determined by your ability in fully utilising the power of
lcomputers. Build that competitive edge over the others, Corporate / personal training available in Petaling Jaya, Kuala
[Lumpur and surrounding areas,
I have been conducting computer training for over 10 years, With almost 20 years of using spreadsheets in the field o'
lfnance I can assure you that quality training with real life examples is what you will get.
|For more details email julian.excel @ gmail.com Don't get left behind in the IT world. On site training available for
lorganisations.
|Courses available in Microsoft Excel are :
[Excel - Basic (I day) / Intermediate (I day) [Managing A Database in Excel (I day)
[Excel - Advance (2 days) [Excel Functions & Formulas (2 days)
[Excel Pivot Tables (I day) [Excel Macro Programming - Basie (2 days)
[Excel - Charts (I day) [Excel Macro Programming - Intermediate (2 days)
[Excel - Financial Analysis & Modeling (2 days) [Not listed above? Just tell me what you need
B=
<
>
htpsheww angelire.com/tiz7juian_sfuanjuians_ macros. Him st