+ Reply to Thread
Results 1 to 8 of 8

Check if the rest of a row is empty?

  1. #1
    Registered User
    Join Date
    11-01-2012
    Location
    Bath
    MS-Off Ver
    Excel 2010
    Posts
    14

    Check if the rest of a row is empty?

    I need a macro which will check if the component it is referencing is the only one in the row, so as in the picture, for the green row, it needs to check that all cells 2 through 10 are empty, then add the contents of G5 to a running total.

    Capture.PNG

    Moving to the next row and finding the first filled column are trivial, I'm just stumped on the single-component check.

    At first I tried to use IsEmpty, as only cells with number are initialized, however, I then learned that IsEmpty doesn't work for ranges. If there a simple command/ line of code I can use?

    g is the row number, i is the number of filled rows (54 in this case) and I used h to find the correct columns. If the code is messy, it's because I started using vba last week ^_^

    Please Login or Register  to view this content.
    Cheers
    Last edited by am462; 11-13-2012 at 08:48 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Check if the rest of a row is empty?

    Instead of a png, it will be good if you attach a sample excel file.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    11-01-2012
    Location
    Bath
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Check if the rest of a row is empty?

    The file is...large (8.5MB) and I think the png capture contains enough visual information?

    I think I could use a new variable to index each column, but this seems like a messy and clunky way of achieving what seems like a straightforward task.

    I just want it to look at a row and say "is there more than one cell with information? If no, add that cell to the right area, if yes, move on the next row."

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Check if the rest of a row is empty?

    Your png does not show the row numbers. It does not show the total field, hence i asked you for a sample file. You do not need to upload your entire file, just a sample of the sheet which you need help with.

  5. #5
    Registered User
    Join Date
    11-01-2012
    Location
    Bath
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Check if the rest of a row is empty?

    Book2.xlsm

    Um. I think that should be ok

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Check if the rest of a row is empty?

    You said -
    for the green row, it needs to check that all cells 2 through 10 are empty, then add the contents of G5 to a running total.
    What about those entries in column I,P and K? Should they be added to the running total ? By the way, where is the cell containing the running total?

    What if there are 2 entries in a row? What should be done in this case?

  7. #7
    Registered User
    Join Date
    11-01-2012
    Location
    Bath
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Check if the rest of a row is empty?

    columns G through P should be counted, from row 5 onwards. The running total can go in row 4 for now, as it serves no function.

    For now, rows with two or more entries can be skipped, as I have not decided what to do in that case.

    I'm just really stuck on telling VBA to find whether there is a single component in the row.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Check if the rest of a row is empty?

    You mean, each column should have its own running total in row 4?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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