Populating and Clearing Fields with a Check Box

DarrylK

New Member
Joined
Mar 6, 2017
Messages
16
Hi,

I am trying to populate and clear fields using a check box.

I have written something long and stupid that will not work. Can someone help me.

This is what I have:

If Sheets("MISC DATA").Range("C18").Value = "TRUE" Then
Range("F5:N5").Select
Selection.Copy
Range("F20:N20").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E7:N7").Select
Application.CutCopyMode = False
Selection.Copy
Range("E22:N22").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E9:N9").Select
Application.CutCopyMode = False
Selection.Copy
Range("E24:N24").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("D11:F11").Select
Application.CutCopyMode = False
Selection.Copy
Range("D26:F26").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I11:J11").Select
Application.CutCopyMode = False
Selection.Copy
Range("I26:J26").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("M11:N11").Select
Application.CutCopyMode = False
Selection.Copy
Range("M26:N26").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E13:G13").Select
Application.CutCopyMode = False
Selection.Copy
Range("E28:G28").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E15:J15").Select
Application.CutCopyMode = False
Selection.Copy
Range("E30:J30").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
If Sheets("MISC DATA").Range("C18").Value = "FALSE" Then
Range("F20:N20,E22:N22,E24:N24,D26:F26,I26:J26,M26:N26,E28:G28,E30:J30").Select
Selection.ClearContents
End If
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Sorry the above was a bad example

I have data in cells A1, C1, E1, G1, & I1
I have a form control check box that is linked to cell E1 on a sheet titled "MISC DATA"

Basically what I am looking to do is:

If the box is checked (If MISC DATA Sheet E1="True") then copy the info from A1 to A9, C1 to C9, E1 to E9...and so on.
And if the box is unchecked (If MISC DATA Sheet E1="False") then clear the data from A9, C9, E9, G9, & I9 by highlighting all the aforementioned cells and deleting the data from those cells.
 
Upvote 0
So if E1 = True then you want E9 to equal true is that what you want.
I'm assuming we are only dealing with one sheet named
MISC DATA

If E1 is on one sheet and data will be copied to another sheet then I need both sheet names.

This script needs no sheet name because I assume the check box and the cells to copy from and to are all on the same sheet.

Code:
Sub Copy_Me()
'Modified 4-6-18 8:15 PM EDT
Dim i As Long
If [E1] = True Then
     For i = 1 To 10 Step 2
        Cells(1, i).Copy Cells(9, i)
    Next
 Else
 
    For i = 1 To 10 Step 2
        Cells(9, i).ClearContents
    Next
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,131
Messages
6,123,222
Members
449,091
Latest member
jeremy_bp001

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