I received this code from an example I found once upon a time that was originally submitted by someone else.
Right now the code enters the current date in a cell of the same row as the checkbox when it's checked.
I need to revise it, or come up with something similar, that will reference the value of a cell when it is in the same row as the button (from the Forms toolbar) that is clicked to activate the macro.
First of all, I don't know how to reference a Forms button in VBA.
Here is the code I found:
- Sub Process_CheckBox()
- Dim cBox As CheckBox
- Dim LRow As Integer
- Dim LRange As String
- LName = Application.Caller
- Set cBox = ActiveSheet.CheckBoxes(LName)
- 'Find row that checkbox resides in
- LRow = cBox.TopLeftCell.Row
- LRange = "B" & CStr(LRow)
- 'Change date in column B, if checkbox is checked
- If cBox.Value > 0 Then
- ActiveSheet.Range(LRange).Value = Date
- 'Clear date in column B, if checkbox is unchecked
- ActiveSheet.Range(LRange).Value = Null
- End If
- End Sub
Here is some other code I already created. Unfortunately, because I don't know how to do the row reference, I had to create 25 different macros, which just bulks up the size of my file and slows it down. But here is what I'm trying to accomplish in my macro:
- Sub ViewRank01()
- Dim sADID As String
- Dim sTime As Integer
- sADID = Range("I6").Value
- sTime = Sheets("Control").Range("D4")
- Application.ScreenUpdating = False
- 'Set Values
- Sheets("ADID History Lookup").Range("E2") = sADID
- Sheets("Control").Range("B50") = sTime
- 'Recalculate Spreadsheet
- 'View History Sheet
- Sheets("ADID History Lookup").Activate
- Application.ScreenUpdating = True
- End Sub
I appreciate any help you can provide.