Announcement

Collapse
No announcement yet.

Adding and Deleting data with Check boxes (Active ex control)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding and Deleting data with Check boxes (Active ex control)



    I have 2 check boxes and based on the selection my macro is coping the data from a location and pasting it in a worksheet.

    I need to make a small upgrade to existing code as when check box is ticked the data get pasted and if we uncheck the box then same data got deleted

    Please check here

  • #2
    There are no attachments

    Comment


    • #3
      Hi,

      I have below codes written for Check box Selection

      Code:
      Sub CheckBox13_Click()
      If Range("V3").Value = True Then
      With Worksheets("Lookup")
              X = .Cells(.Rows.Count, "O").End(xlUp).Row
              LastRow = X + 1
          End With
      Range("Channel_EM").Copy Cells(LastRow, 14)
      End If
      End Sub
      
      Sub CheckBox14_Click()
      If Range("V4").Value = True Then
      With Worksheets("Lookup")
              X = .Cells(.Rows.Count, "O").End(xlUp).Row
              LastRow = X + 1
          End With
      Range("Channel_EM").Copy Cells(LastRow, 14)
      End If
      End Sub
      I just want to undo the same when checkbox delected

      Comment


      • #4


        By the looks of it your code figures out the last non blank row in the LOOKUP sheet in column O, then copies named range Channel_EM to the current sheet column N, same row number as that from LOOKUP sheet but to column N.
        Checkbox 13 Is checking if cell V3 of current sheet is TRUE and Checkbox14 is checking if V4 is true but they do the same job so assuming that these are the linked cells for the checkboxes?
        My question is then are you overwriting an existing value in column N when you tick your checkbox? Or are you just pasting it in an empty cell in column N?

        If you are overwriting existing value, then you can't get the old value back unless you save the original value first in a Global variable & then paste it back in when checkbox is unticked.
        If you are just pasting it in a blank cell in column N then you'll need to store the row number it was pasted into as a Global Variable & then ClearContents the cell out when checkbox is unticked

        Comment

        Working...
        X