+ Reply to Thread
Results 1 to 9 of 9

Code to fill cells with check box or data entry

  1. #1
    Registered User
    Join Date
    09-17-2011
    Location
    Alberta
    MS-Off Ver
    Excel 2010
    Posts
    63

    Code to fill cells with check box or data entry

    Hello

    See attached, is there some way to have cells filled when check box entered but if check box not checked can enter data into cell

    Thanks Jeff
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Code to fill cells with check box or data entry

    Right click on the box and assign this macro
    Please Login or Register  to view this content.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    09-17-2011
    Location
    Alberta
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Code to fill cells with check box or data entry

    When I put in my actual sheet I get subscript out of range error, any chance if I send you my sheet you can have a look

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Code to fill cells with check box or data entry

    Check this line: Set sh = Sheets("Sheet1") make sure your actual sheet name is between the quotes.

  5. #5
    Registered User
    Join Date
    09-17-2011
    Location
    Alberta
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Code to fill cells with check box or data entry

    Ok I got it to work for 1st set, now I want to add 2 more of the same in different spots.

    I have put 1st one in module 3, where do i put the rest

    This is the one that works

    Sub Change_Box()
    Dim sh As Worksheet

    Set sh = Sheets("DRIFLO")

    If sh.Range("$q$16") = True Then
    ' Fill Cells
    sh.Range("$I$17:$I$28").Copy Range("$m$17")
    Else
    ' Clear Contents
    sh.Range("$m$17:$m$28").ClearContents

    End If

    End Sub


    Here are the next 2 I want to add

    Have[/B] to work independent of each other[/B]

    Sub Change_Box()
    Dim sh As Worksheet

    Set sh = Sheets("DRIFLO")

    If sh.Range("$q$32") = True Then
    ' Fill Cells
    sh.Range("$i$34:$i$39").Copy Range("$m$34")
    Else
    ' Clear Contents
    sh.Range("$m$34:$m$39").ClearContents
    End If

    End Sub



    Sub Change_Box()
    Dim sh As Worksheet

    Set sh = Sheets("DRIFLO")

    If sh.Range("$q$44") = True Then
    ' Fill Cells
    sh.Range("$g$46:$g$48").Copy Range("$m$46")
    Else
    ' Clear Contents
    sh.Range("$g$46:$m$48").ClearContents
    End If

    End Sub


    THANK YOU ALL FOR YOUR HELP

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Code to fill cells with check box or data entry

    Give each one of these macros a different name. Then right click on the checkbox - one of the options is Assign Macro. Pick the macro that goes along with that checkbox.

  7. #7
    Registered User
    Join Date
    09-17-2011
    Location
    Alberta
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Code to fill cells with check box or data entry

    OK making progress, I got that spreadsheet done.

    Moved to next sheet and when i debug it goes here

    Set sh = Sheets("ELECTRONIC EFM")

    This is what sheet is called

    ELECTRONIC EFM

    Whjat else would make this fail?


    Here is code

    Sub Change_Box()
    Dim sh As Worksheet

    Set sh = Sheets("ELECTRONIC EFM")

    If sh.Range("$q$16") = True Then
    ' Fill Cells
    sh.Range("$I$27:$I$32").Copy Range("$m$27")
    Else
    ' Clear Contents
    sh.Range("$m$27:$m$32").ClearContents

    End If

    End Sub

  8. #8
    Registered User
    Join Date
    09-17-2011
    Location
    Alberta
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Code to fill cells with check box or data entry

    Never mind figured that out.

    But now with one check box I want to copy f48 to f50 as well as g48 to G50 over to k48 to k50 and m48 to m50

    Code I used for single row, now I need multiple row see bold

    Sub CheckBox283_Click()

    Dim sh As Worksheet

    Set sh = Sheets("ELECTRONIC EFM")

    If sh.Range("$q$24") = True Then
    ' Fill Cells
    sh.Range("$I$36:$I$41").Copy Range("$m$36")
    Else
    ' Clear Contents
    sh.Range("$m$36:$m$41").ClearContents

    End If

    End Sub

    Thanks in advance fo rhrlp

  9. #9
    Registered User
    Join Date
    09-17-2011
    Location
    Alberta
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Code to fill cells with check box or data entry

    Got it. Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 02-12-2016, 01:54 PM
  2. [SOLVED] Add vba code to lock cells on data entry
    By timetoshine in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-11-2014, 08:36 AM
  3. [SOLVED] Having a macro check for changes in two drop down lists and fill in cells with data (2013)
    By cueball19826 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2013, 02:38 AM
  4. [SOLVED] Vba code to fill check in & check out counts
    By ashfaquebwd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2013, 09:02 AM
  5. [SOLVED] VBA code for reference cells data check
    By JohnSavag in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2012, 12:12 PM
  6. Code to check for duplicate entry
    By renden in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-02-2012, 05:00 AM
  7. Auto Fill off of zip code entry
    By KLahvic in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-21-2009, 11:07 AM

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