Date: Fri, 24 Aug 2007 14:23:46 -0500 (CDT) From: Mark Jacobson To: 810-022-01-fall@uni.edu Subject: Monday and Wednesday - Excel VBA macros... Hi 022 students, We will focus on Excel and Visual Basic for Applications macros on Monday in the classroom class. On Wednesday, we will look into Excel VBA further in the WRT 112 lab again. Next Friday, in StudioIT 2 will be devoted to introducing you further to Flash graphics and animation again. Look over the birthday problem handout from last Wednesday's lab and/or look over the online PowerPoint web slide show on the birthday problem (it seems to require Internet Explorer and doesn't work in Mozilla Firefox). http://www.cns.uni.edu/~jacobson/dodea/ExcelVBAMacrosBirthdays.htm 1. Look at the First two macros. ConvertFormulasToValues() we did in the lab on Wednesday. Edit menu, Copy Edit menu, Paste Special, check the Values only checkbox. Press the Esc (Escape) key SortSelection() sorts the raw values into ascending order from the January numbers to the December numbers. Recall 33 would be February 2nd. 364 would be December 30th. 2. Look at the VBA code for Version #2. It has a Sub Run100() that looks like this: Sub Run100() For i = 1 to 100 Birthdays23 Next i End Sub For Next loops will be used quite often in VBA and in this 810:022 course. The above loop will cause the Birthdays23 macro to be run or repeated 100 times. For i = 1 to 100 ... actions to repeat 100 times ... Next i 3. Look at the VBA code for Version #2. Notice that the TallyTheResult() macro has a For Each loop. For Each theCell In Range("B3:B24") ... actions to be performed on each and every cell ... Next theCell 4. Review chapter one (Lesson One) of the Excel VBA textbook by Reed Jacobson too. It covers the basics and has an example of the Not logical operator. ActiveWindow.DisplayFormulas = True we modified, so it was: ActiveWindow.DisplayFormulas = Not ActiveWindow.DisplayFormulas --- With Not we can Toggle the DisplayFormulas back and forth from True to False or from False to True. Have a great weekend. Hopefully, the rain will stop and stay stopped for 5 or 10 days! Mark