Howdy folks, hope I can throw in a few q's that I'm trying to grasp. Every little bit s! Thanks in advance! Starting with the least code:
1) For module-level variables, is Dim the same thing as Private?
2) If we want to assign a variable to a method or property, would that variable always be a variant?
3) For event-handler procedures, is it fair to say you can't have more than one of the same type [e.g., Workbook_Open() ]?
4) Sorry for a silly question, but is & the same thing as + (aside from addition)?
5) Consider the following, a simple procedure that modifies even-# columns with a new width:
6) For any Sub procedure, let's say:
So is it fair to say that () doesn't take arguments? Is that idea similar to optional arguments?
7) Consider a simple event-handler procedure that asks you if you want back-up your work before you close Excel:
I was curious, what does Cancel do here exactly? And can I replace vbYesNo with, let's say, the inputbox function?
Cheers!
1) For module-level variables, is Dim the same thing as Private?
2) If we want to assign a variable to a method or property, would that variable always be a variant?
3) For event-handler procedures, is it fair to say you can't have more than one of the same type [e.g., Workbook_Open() ]?
4) Sorry for a silly question, but is & the same thing as + (aside from addition)?
5) Consider the following, a simple procedure that modifies even-# columns with a new width:
I was wondering what data type is Col? The procedures runs fine as a Variant, but I don't know if its a Long or a ("column") object. It would make sense if it was an object, since that would explain the idea of "Col.Column", i.e. instance of an object.Sub widthAdjust()
Dim Col
For Each Col In Worksheets("Sheet7").Columns
If Col.Column Mod 2 = 0 Then Col.ColumnWidth = 8.43
Next Col
End Sub
6) For any Sub procedure, let's say:
Code:
[COLOR=darkorange]Sub myprocedure()[/COLOR]
[I][COLOR=darkorange]statements[/COLOR][/I]
[COLOR=darkorange]End Sub[/COLOR]
7) Consider a simple event-handler procedure that asks you if you want back-up your work before you close Excel:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Code:
[B]Dim Msg As String[/B]
[B]Dim Ans As Integer[/B]
[B]Dim FileName As String[/B]
[B]Msg = “Would you like to make a backup of this file?”[/B]
[B]Ans = MsgBox(Msg, vbYesNo) '//vbYesNo is an argument[/B]
[B]If Ans = vbYes Then[/B]
[B] FileName = “F:\BACKUP\” & ThisWorkbook.Name[/B]
[B] ThisWorkbook.SaveCopyAs FileName[/B]
[B]End If[/B]
[B]End Sub[/B]
Cheers!