VBA code explanation

  • Thread starter Thread starter Khalil Handal
  • Start date Start date
K

Khalil Handal

This is the code when pressing a button on the sheet. It will print the
sheet after changing the values of some cells ... I am wondering how it
works and what is the value of the []?
P4, Q4 are cells on the active sheet. One of the sheets has the name Q

Sub printForm1A()
For AH = [P4] To [Q4]
[Q1] = AH
ActiveWindow.SelectedSheets.PrintPreview
Next
Range("A1").Select
End Sub
 
The [] is a lazy shorthand way of saying Range(".."), it is evaluating the
contents of [].
 
thanks

Bob Phillips said:
The [] is a lazy shorthand way of saying Range(".."), it is evaluating the
contents of [].

--
__________________________________
HTH

Bob

Khalil Handal said:
This is the code when pressing a button on the sheet. It will print the
sheet after changing the values of some cells ... I am wondering how it
works and what is the value of the []?
P4, Q4 are cells on the active sheet. One of the sheets has the name Q

Sub printForm1A()
For AH = [P4] To [Q4]
[Q1] = AH
ActiveWindow.SelectedSheets.PrintPreview
Next
Range("A1").Select
End Sub
 
Back
Top