excelbytes
Active Member
- Joined
- Dec 11, 2014
- Messages
- 291
- Office Version
- 365
- Platform
- Windows
I have the following code:
However, I don't want to insert MP0 in the range B2:B50, rather start at B2 and only enter it based on the count from another worksheet:
How can I combine these so that it will only enter MP0 starting in cell B2 and going down as far as the count in the OFFICIAL DRAFT worksheet D15:D100?
Thanks!
VBA Code:
Private Sub CheckBox2_Click()
On Error Resume Next
On Error GoTo err_handler
If CheckBox2.Value = True Then Sheets("IC304").Range("B2:B50").Value = "MP0"
If CheckBox2.Value = False Then Sheets("IC304").Range("B2:B50").Value = ""
If CheckBox2.Value = True Then Sheets("TH102").Range("B2:B50").Value = "MP0"
If CheckBox2.Value = False Then Sheets("TH102").Range("B2:B50").Value = ""
Exit Sub
err_handler:
MsgBox "Error number: " & Err.Description, vbExclamation, Err.Number
Exit Sub
End Sub
However, I don't want to insert MP0 in the range B2:B50, rather start at B2 and only enter it based on the count from another worksheet:
VBA Code:
Sub CountCells()
Dim ws As Worksheet
Set ws = Worksheets("OFFICIAL DRAFT")
Application.WorksheetFunction.CountA(ws.Range("D15:D100"))
End Sub
How can I combine these so that it will only enter MP0 starting in cell B2 and going down as far as the count in the OFFICIAL DRAFT worksheet D15:D100?
Thanks!