Results 1 to 3 of 3

Thread: finding first blank row

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    See if this helps you.

    Code:
    Sub UpdateSheet2()
        
        Dim rngSource       As Range
        Dim RegNum          As String
        Dim rngRegNum       As Range
        Dim varFound, i     As Long
        
        
        With Sheet1
            Set rngSource = .Range("a3:h" & .Range("b" & .Rows.Count).End(xlUp).Row)
        End With
        
        With Sheet2
            Set rngRegNum = .Range("b1:b" & .Range("b" & .Rows.Count).End(xlUp).Row)
        End With
        
        '//loop through all the reg. #
        For i = 1 To rngSource.Rows.Count
            
            '//reg. # in 2nd column
            RegNum = rngSource.Cells(i, "b")
            
            '//look for the reg # in sheet2
            varFound = Application.Match(RegNum, rngRegNum, 0)
            
            '//if found, update the data
            If Not IsError(varFound) Then
                
                '//found cell
                With rngRegNum.Cells(varFound, 1)
                    .Offset(, -1).Value2 = rngSource.Cells(i, 1).Value2   'Customers Name
                    .Offset(, 1).Value2 = rngSource.Cells(i, 5).Value2    '1ST serice costs
                    .Offset(, 2).Value2 = rngSource.Cells(i, 6).Value2    '2nd service costs
                    .Offset(, 3).Value2 = rngSource.Cells(i, 7).Value2    'Bugeted costs
                    .Offset(, 4).Value2 = rngSource.Cells(i, 8).Value2    'End Date
                End With
            End If
        Next
        
    End Sub
    Last edited by Admin; 12-31-2013 at 05:37 PM.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Replies: 0
    Last Post: 12-24-2013, 01:36 PM
  2. Replies: 2
    Last Post: 02-11-2013, 08:13 PM
  3. Autofill the data based on non blank cell in next row?
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 3
    Last Post: 11-29-2012, 04:16 PM
  4. Replies: 2
    Last Post: 09-24-2012, 11:19 PM
  5. Finding Last Used Row or Column In Excel Sheet
    By Rasm in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 04-14-2011, 03:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •