+ Reply to Thread
Results 1 to 5 of 5

Toggle Button To Fill In Blank Cells With N/A

  1. #1
    Forum Contributor
    Join Date
    01-12-2012
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    104

    Toggle Button To Fill In Blank Cells With N/A

    Hello,

    I have the attached spreadsheet where I need to fill in any blank cells with "N/A".
    The range is quite large, so with the current code, it takes a long time to run.

    Is there any way to make this more efficient?:

    Please Login or Register  to view this content.
    Many Thanks!
    Storm08
    Attached Files Attached Files
    Last edited by Storm08; 12-02-2022 at 12:34 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this !


    According to your attachment use Excel / VBA basics at once rather than such slow looping cell by cell :

    PHP Code: 
    Private Sub Toggle_NA_Click()
        
    With ActiveSheet.UsedRange.Rows("3:" ActiveSheet.UsedRange.Rows.Count)
            If 
    Toggle_NA.Value Then On Error Resume Next: .SpecialCells(4) = "N/A" Else .Replace "N/A", Empty
        
    End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 12-02-2022 at 12:13 PM. Reason: typo ?

  3. #3
    Forum Contributor
    Join Date
    01-12-2012
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    104

    Re: Hello, try this !

    Quote Originally Posted by Marc L View Post

    According to your attachment use Excel / VBA basics at once rather than such slow looping cell by cell :

    PHP Code: 
    Private Sub Toggle_NA_Click()
        
    With ActiveSheet.UsedRange.Rows("3:" ActiveSheet.UsedRange.Rows.Count)
            If 
    Toggle_NA.Value Then On Error Resume Next: .SpecialCells(4) = "N/A" Else .Replace "N/A", Empty
        
    End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Wow. That code is great! Thank you.

    One more question.

    If I wanted to change the range where this code runs, how would I do that?
    For instance, if I wanted to run the code in Range("A2:B110"), how would I change that code?

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Toggle Button To Fill In Blank Cells With N/A


    In the With Codeline …

  5. #5
    Forum Contributor
    Join Date
    01-12-2012
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    104

    Re: Toggle Button To Fill In Blank Cells With N/A

    Sorry, that was a very obvious question! I just figured it out too

    Thank you very much Marc!

    +Rep!

+ 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. Button to Toggle Text between two cells
    By SportsAnnouncing in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-01-2020, 11:07 AM
  2. [SOLVED] Toggle Button to hide/unhide blank rows
    By therealaccountant in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-05-2019, 07:56 PM
  3. [SOLVED] how do i make a toggle button change other toggle buttons value to false
    By kevinu in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-10-2018, 04:19 PM
  4. [SOLVED] Toggle Button to filter empty cells or cells with values
    By goomblar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2014, 10:31 AM
  5. Toggle Button Does not Toggle OFF when Clicked
    By robbfamily in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-19-2014, 05:12 PM
  6. [SOLVED] Toggle fill Color in cell based on condition of cell--blank or text added.
    By moosetales in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2014, 08:39 PM
  7. Replies: 1
    Last Post: 02-13-2014, 10:55 PM

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