What is the syntax to see if a checkbox is checked?

 <userform name>.<checkbox name>.Value
'example
If formHome.chkActiveOnly.Value = True Then
    MsgBox "User has checked the box"
Else
    MsgBox "User has not checked the box"
End If

 

Advertisements

What is the syntax to write to another workbook?

'to retrieve data
Workbooks("<workbook file name>").Worksheets("<sheet name>").Range("<your range>").Value
Workbooks("<workbook file name>").Worksheets("<sheet name>").Cells(<row number>, <column number>).Value

'to set data
Workbooks("<workbook file name>").Workbooks("Worksheets("<sheet name>").Range("<your range>") = <your value/data>
Workbooks("<workbook file name>").Worksheets("<sheet name>").Cells(<row number>, <column number>).Value = <your value/data>
'examples
Workbooks("example.xlsm").Worksheets("Example").Range("A1:A4") = "hello"
Workbooks("book3.xlsx").Worksheets("Example").Range("D1") = "world"
Workbooks("book3.xlsx").Worksheets("Example").Cells(2, 4).Value = "goodbye"

What is the syntax to use/set data in another sheet?

'to retrieve data
Worksheets("<sheet name>").Range("<your range>").Value
Worksheets("<sheet name>").Cells(<row number>, <column number>).Value

'to set data
Worksheets("<sheet name>").Range("<your range>") = <your value/data>
Worksheets("<sheet name>").Cells(<row number>, <column number>).Value = <your value/data>
'examples
Worksheets("Example").Range("A1:A4") = "hello"
Worksheets("Example").Range("D1") = "world"
Worksheets("Example").Cells(2, 4).Value = "goodbye"

Capture.PNG

What is the syntax to format borders?

Range(“<cell reference>”).Borders.LineStyle= <line style>
Range(“<cell reference>”).Borders.Weight = <thickness style>
Range(“<cell reference>”).Borders.Color= <rgb color>
  • Line style options: xlContinuous, xlDot, xlDashDotDot, xlDash, xlSlantDashDot, xlDouble
  • Thickness options: xlThin, xlMedium, xlThick
‘examples
Range(“B4”).Borders.LineStyle= xlDash
Range(“B4”).Borders.Color= rgbBlueViolet