Results 1 to 4 of 4

Need to check is cells are empty before pasting

Threaded View

  1. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need to check is cells are empty before pasting

    This is still clear as mud for me. Maybe this will explain things for you

    Sub Example()
    Dim row_number As Long, num_blanks As Long
    Dim rng As Range
    
    'in this situation Range B8 is 12
    row_number = Sheets("Data").Range("B8").Value + 3
    
    'this will resize your range to encorporate columns B to GG for that given row_number
    Set rng = Sheets("Current").Cells(row_number, 2).Resize(1, 188)
    
    'proof it works
    MsgBox rng.Address
    
    
    'to see if there is at least 1 empty cell in rng
    num_blanks = Application.WorksheetFunction.CountBlank(rng)
    
    'proof it works
    If Application.WorksheetFunction.CountBlank(rng) > 0 Then
        MsgBox ("There are " & num_blanks & " blank cells in Range" & rng.Address)
    Else
        MsgBox ("There are no blanks in Range" & rng.Address)
    End If
     
    End Sub
    Last edited by stnkynts; 02-05-2015 at 05:16 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need to check if cells empty before pasting
    By karlosdejackal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2015, 03:20 PM
  2. Empty cells not evaluating as empty - multiple check methods tried
    By rafadavidc in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-03-2014, 05:54 PM
  3. pasting values into EMPTY cells
    By jonny9781 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2008, 07:44 AM
  4. Check for empty cells but ignoring value ZERO
    By munkayboi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2007, 02:10 PM
  5. check for non-empty cells outside of a certain range
    By Abe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-28-2006, 01:50 PM

Tags for this Thread

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