I thank you very much for taking the time to read, and apologize in advance for these ABCs (annoying, boring and possibly conceptual questions). Nonetheless, I'm very grateful for any thoughts on any one of them (many of which are actually observations). In any event:
1) For If-Then-Else statements, is the Else keyword effectively the same as Else: (i.e. with a colon)? (As far as I can tell they are, from the lack of errors when compiling)
2) Suppose that
Is the latter line, Range().Copy, always the exact same thing as Selection.Copy (and possibly ActiveCell.Copy) in general?
3) Is it fair to say that for all user-made Functions, that they must have a (main) variable of the same name and that if not declared otherwise, they are treated as variants?
4) If we wanted to use If-Then for a bunch of conditions, I believe we can either use a series of strictly If-Then, or a series of If-Then-ElseIf (where End If seems to be always required, but usually not so for the former). For the latter, is it true we don't necessarily need to wrap the conditions up with the keyword "Else"? For example:
5) For a given cell or variable, is it fair to say that if they are Null, it means they have a value that has yet to be determined, while Empty means it is blank, undefined or "nothing"? (And if I'm not mistaken, the memory address of Null is fixed, and the memory address of Empty hasn't been determined). Or is it the other way around (in any language)? I'm getting confused since different sources from Google seem to be give me opposing information).
6) And this isn't really a question; I just found it interesting that the ActiveCell in this example (among others) doesn't change when being Offset (variable,fixed):
Compared with,
Again, any feedback welcomed!!!!!!!!!!!
1) For If-Then-Else statements, is the Else keyword effectively the same as Else: (i.e. with a colon)? (As far as I can tell they are, from the lack of errors when compiling)
2) Suppose that
Rich (BB code):
Range("A1:A6").Select '//you can use With-End With structure
Range("A1:A6").Copy
3) Is it fair to say that for all user-made Functions, that they must have a (main) variable of the same name and that if not declared otherwise, they are treated as variants?
4) If we wanted to use If-Then for a bunch of conditions, I believe we can either use a series of strictly If-Then, or a series of If-Then-ElseIf (where End If seems to be always required, but usually not so for the former). For the latter, is it true we don't necessarily need to wrap the conditions up with the keyword "Else"? For example:
Rich (BB code):
'This simply returns the price with appropriate discount
Dim Amount
Amount = InputBox("Enter Amount: ")
If Amount > 0 And Amount < 25 Then
Discount = 0.12
ElseIf Amount >= 25 And Amount < 60 Then
Discount = 0.2
ElseIf Amount >= 60 Then
Discount = 0.25
MsgBox "Your Price: " & Amount*(1-Discount)
End If
End Sub
5) For a given cell or variable, is it fair to say that if they are Null, it means they have a value that has yet to be determined, while Empty means it is blank, undefined or "nothing"? (And if I'm not mistaken, the memory address of Null is fixed, and the memory address of Empty hasn't been determined). Or is it the other way around (in any language)? I'm getting confused since different sources from Google seem to be give me opposing information).
6) And this isn't really a question; I just found it interesting that the ActiveCell in this example (among others) doesn't change when being Offset (variable,fixed):
Rich (BB code):
'this assigns random numbers to 25 cells
Sub FillintheRange()
Dim Counter As Long
For Counter = 0 To 24
ActiveCell.Offset(Counter, 0) = Rnd
Next Counter
End Sub
Rich (BB code):
Sub MyRelativeMacro()'this fills some ranges one after another with a word
ActiveCell.FormulaR1C1 = "Lemons"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "Pineapples"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "Bananas"
ActiveCell.Offset(0, -2).Range("A1").SelectEnd Sub