Results 1 to 8 of 8

Check if the rest of a row is empty?

Threaded View

  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 ^_^

    Sub Fraction_Counter()
    
    g = 5
    
    Do While g < i
    h = 7
    
    If IsEmpty(Worksheets("Fractions").Cells(g, h)) Then
    h = h + 1
    
    ElseIf h = 7 And IsEmpty(Worksheets("Fractions").Range(cells(g,8),cells(g17))) Then
     Worksheets("Front End").Cells((h + 7), 10) = Worksheets("Front End").Cells((h + 7), 10) + Worksheets("Fractions").Cells(g, h)
     
    ElseIf h = 17 And IsEmpty(Worksheets("Fractions").Range(Cells(g, 7), Cells(g, 16))) Then
    Worksheets("Front End").Cells(h + 7, 10) = Worksheets("Front End").Cells(h + 7, 10) + Worksheets("Fractions").Cells(g, h)
     
    ElseIf IsEmpty(Worksheets("Fractions").Range(Cells(g, 7), Cells(g, h - 1))) And IsEmpty(Worksheets("Fractions").Range(Cells(g, h + 1), Cells(g, 17))) Then
    
        Worksheets("Front End").Cells(h + 7, 10) = Worksheets("Front End").Cells(h + 7, 10) + Worksheets("Fractions").Cells(g, h)
        
    Else
    g = g + 1
    End If
    'g = g + 1
    'Loop
    
    End Sub
    Cheers
    Last edited by am462; 11-13-2012 at 08:48 AM.

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