vba code to enter number selected row

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,375
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I need some help with some vba code for my spreadsheet. I have an excel table and I need a 1.1 to be entered in to column AB of a selected row upon the selection of a checkbox, and if the checkbox is unselected, I need it to go back to a 1. My table is tblCosting and the worksheet is called home.
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Assuming the checkbox is a form control and is called check box 1, bind this sub to the check box

Code:
Sub SetColAB()


Dim cb As Shape
Dim ws As Worksheet
    
    Set ws = Worksheets("home")
    Set cb = ws.Shapes("Check Box 1")
    
    ws.Cells(ActiveCell.Row, "AB") = IIf(cb.ControlFormat.Value = 1, 1.1, 1)
    
End Sub
 
Last edited:
Upvote 0
Assuming the checkbox is a form control and is called check box 1, bind this sub to the check box

Code:
Sub SetColAB()


Dim cb As Shape
Dim ws As Worksheet
    
    Set ws = Worksheets("home")
    Set cb = ws.Shapes("Check Box 1")
    
    ws.Cells(ActiveCell.Row, "AB") = IIf(cb.ControlFormat.Value = 1, 1.1, 1)
    
End Sub

Do I put the code in the on change event of the check box?
 
Upvote 0
Sorry, I didn't fully read your post. No need for the last question.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top