Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Excel - Copy True/False Values in Checkboxes to Another Workbook

I am trying work how to copy the contents of checkboxes (ie the TRUE/FALSE part) into another workbook. This is part of a macro to copy several different values and put in a summary table.

What I am trying to find out is:

  1. How to select the checkbox in the source spreadsheets
  2. How to put the value (TRUE/FALSE) in the destination spreadsheet.

The other values are being copied across in the loop that looks at all the spreadsheets in a selected folder, for example:

 'Define where the source data is located in DP Calculator
    Set SourceRangeID = WorkBk.Worksheets("Calculator").Range("B12")     

 'Set the destination ranges in Summary Sheet
    Set DestRangeID = WksSummary.Range("b" & NRow)

 'Copy over the values from the source to Summary Sheet
    DestRangeID.Value = SourceRangeID.Value

There are a number of lines like these defining each source and destination range.

Ideally the copying of the checkbox will slot into these lines.

Thank you very much

To clarify I have tried:

Dim SourceRangeNewDP As Checkbox Dim DestRangeNewDP As Range Set SourceSavingsNewDP = WorkBk.Worksheets("Calculator").CheckBoxes("Check Box 5").Value DestRangeNewDP.Value = SourceSavingsNewDP.Value

which gave an error Run Time Error 13 Type Mismatch

I next tried: Dim SourceRangeNewDP As Checkbox Dim DestRangeNewDP As Range If WorkBk.Worksheets("Calculator").CheckBoxes("Check Box 5").Value = True Then DestRangeNewDP.Value = "YES" Else
DestRangeNewDP.Value = "NO" End if

which does work, but seems a bit convoluted. I would be good to know if this can be done without using the IF ELSe statement.

Thanks

Comments