+ Reply to Thread
Results 1 to 4 of 4

Need to check is cells are empty before pasting

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

    Need to check is cells are 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 is cells are empty before pasting

    Do you mean like this?

    Please Login or Register  to view this content.

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

    Re: Need to check is cells are empty before pasting

    Hi,

    Thank you for your offer of help, but this is not what I am really looking for.

    For example if value 12 is put in the day box (Sheets("Data").Range("B8").Value) , then data gets pasted to Sheets("Current").Cells(row_number, 2)

    I need the macro to look across row_number and from columns B - GG. To see if these are empty

    The issue is I don't know how to define this range using row_number and get it to check that there is no data before pasting

    In this example it would be Range (15B:15GG). But I need the row to change with row_number.

    Thanks

  4. #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

    Please Login or Register  to view this content.
    Last edited by stnkynts; 02-05-2015 at 05:16 PM.

+ 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. 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