+ Reply to Thread
Results 1 to 5 of 5

checkbox to take a value from one cell and put it into another cell

Hybrid View

  1. #1
    Registered User
    Join Date
    10-30-2008
    Location
    Canada
    Posts
    3

    checkbox to take a value from one cell and put it into another cell

    hi
    I am new here and would like to say hello to all of you guys here
    anyway, I try to build a matrix with checkbox and say if I click to the checkbox, then it will take a value (say A1) and put that value into another cell (say A2)
    Can someone help me with the code
    thanks
    Last edited by VBA Noob; 11-01-2008 at 03:30 AM.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: checkbox to take a value from one cell and put it into another cell

    See what you can do with this
    Attached Files Attached Files
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Registered User
    Join Date
    10-30-2008
    Location
    Canada
    Posts
    3
    Sub Process_CheckBox()
    'This sub is assigned to all checkboxes on sheet1
    'Cheched: Show Date
    'Unchecked: Cell.Value = NULL (empty)
    
        Dim cBox As CheckBox
        Dim LRow As Integer
        Dim LRange As String
        
        LName = Application.Caller ' Multiple object are assigned to this Macro. Which is Calling this macro
        Set cBox = ActiveSheet.CheckBoxes(LName)  ' make pointer to this object
        
        'Find row that checkbox resides in
        LRow = cBox.TopLeftCell.Row 'In which Cell (and Row) is the TopLeft corner of the Checkbox
        LRange = "B" & CStr(LRow) 'All in Column "B"
        
        'Change date in column B, if checkbox is checked
        If cBox.Value > 0 Then '0: UnChecked, 1: Checked
            ActiveSheet.Range(LRange).Value = Date
            
        'Clear date in column B, if checkbox is unchecked
        Else
            ActiveSheet.Range(LRange).Value = Null
        End If
        
    End Sub
    -----
    this is what I get out of the macro
    can you help me fix the macro to do precisely as stated, I know nothing about VB
    thanks
    Last edited by royUK; 10-31-2008 at 12:37 PM.

  4. #4
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: checkbox to take a value from one cell and put it into another cell

    Please read the forum rules and put the Code between ## so it will appear as follows:
    Sub Process_CheckBox()
    'This sub is assigned to all checkboxes on sheet1
    'Cheched: Show Date
    'Unchecked: Cell.Value = NULL (empty)
    
        Dim cBox As CheckBox
        Dim LRow As Integer
        Dim LRange As String, RRange As String
        
        LName = Application.Caller ' Multiple object are assigned to this Macro. Which is Calling this macro
        Set cBox = ActiveSheet.CheckBoxes(LName)  ' make pointer to this object
        
        'Find row that checkbox resides in
        LRow = cBox.TopLeftCell.Row 'In which Cell (and Row) is the TopLeft corner of the Checkbox
        LRange = "A" & CStr(LRow) 'All in Column "B"
        RRange = "B" & CStr(LRow) 'All in Column "B"
        
        'Change date in column B, if checkbox is checked
        If cBox.Value > 0 Then '0: UnChecked, 1: Checked
            ActiveSheet.Range(RRange).Value = ActiveSheet.Range(LRange).Value
            
        'Clear date in column B, if checkbox is unchecked
        Else
            ActiveSheet.Range(RRange).Value = Null
        End If
        
    End Sub
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-30-2008
    Location
    Canada
    Posts
    3
    beautiful
    thanks for the great help here, rwgrietveld

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1