+ Reply to Thread
Results 1 to 4 of 4

What if there is no data for the macro to run off of?

  1. #1
    Registered User
    Join Date
    11-17-2014
    Location
    Denver, CO
    MS-Off Ver
    2010
    Posts
    5

    What if there is no data for the macro to run off of?

    Each day, a user will cut and paste data into two different sheets of a workbook. I have a macro set up that will splice all the data the way we need it and then move the data from one to the other so I have all the data in one sheet. I used Private Subs to get all the information set up.

    Sub Verifications()
    Call RemoveNR
    Call Zone
    Call DataMove
    Call Format


    End Sub

    The first 3 calls are for Sheet 2. Sometimes there is not any data to go in this sheet(each day new data is put into both sheets). It causes the macro to fail in the first Private Sub. How can I have it to look to see if data exist before the rest of the macro finish? Basically saying something like "if data exists continue, if not end sub". Here is what the first private sub looks like.

    rivate Sub RemoveNR()

    Sheets("I+ Report").Select

    Dim i As Integer

    For i = Range("AA1").End(xlDown).Row To 2 Step -1
    If InStr(Cells(i, 27), "NR ") = 0 Then
    Rows(i).Delete Shift:=xlUp
    End If
    Next i

    End Sub

    Thanks for your help. I will have close to 50 users that will use this macro and most are not excel savvy in the slightest.

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

    Re: What if there is no data for the macro to run off of?

    Maybe

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-17-2014
    Location
    Denver, CO
    MS-Off Ver
    2010
    Posts
    5

    Re: What if there is no data for the macro to run off of?

    Thanks for responding so fast.

    That worked for not running the macro. I do need to run the "Call Format" reguardless if there is not any data in the I+ Report sheet. How can I make sure that one runs but not the others?

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

    Re: What if there is no data for the macro to run off of?

    Surprised you could figure this one out on your own.

    Please Login or Register  to view this content.

+ 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. automatic macro with linking data in two workbooks, multiple row data to one row data
    By garfield8626 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-02-2013, 01:47 PM
  2. [SOLVED] excel 2007 chart macro graphs data only from sheet on which macro was recorded
    By JW1028 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-19-2013, 06:33 PM
  3. Macro to download monthly stock data and to refresh that data with the macro
    By Frankdude in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-23-2011, 08:38 PM
  4. Creating a macro to auto-update external data and time macro was excecuted
    By UNWATCHABLE in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2010, 05:21 AM
  5. Optimizing Excel macro to find/replace with the list of data contained in the macro
    By Iceyburnz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2008, 08:41 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