+ Reply to Thread
Results 1 to 2 of 2

Need to check if cells empty before pasting

  1. #1
    Registered User
    Join Date
    01-23-2015
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    10

    Need to check if cells empty before pasting

    Hi,

    I have written a simple copy&paste macro.

    I was wondering if anyone had any suggestions for how to check if there is no data on the row before pasting? (Seeing as there is no undo)

    I guess I need and If IsEmpty type function and Else then give an error.


    Sub Update_Month()

    ' Update the fills for the specific day

    Dim number As Integer
    Dim row_number As Integer

    'enter number in day box at B8, then this will paste to the correct place on sheet

    row_number = Sheets("Data").Range("B8").Value + 3

    'I need an if statement for here I think that looks at the row entered (row_number) and checks that it is empty or zero from column 2 to 500

    Sheets("Data").Select
    Range("A5:HD5").Select
    Selection.Copy
    Sheets("Current").Select
    Cells(row_number, 2).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    'Else an error message

    End Sub


    Could anyone help me on this? Particularly in using my row_number to look across a range.

    Thanks

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

    Re: Need to check if cells empty before pasting

    Duplicate post.

    See http://www.excelforum.com/excel-prog...e-pasting.html

+ 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. 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
  2. [SOLVED] Check for empty cells on exit
    By Noneil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2013, 08:12 AM
  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 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
  5. [SOLVED] check for non-empty cells outside of a certain range
    By Abe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-28-2006, 11:45 AM

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