Results 1 to 3 of 3

Thread: finding first blank row

  1. #1
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    12

    finding first blank row

    Hi All

    I have attached a small wb, this mirrors certain cells from sheet1 to sheet 2 but because it jst mirrors it copies them into the
    same row on sheet two. I need the data to update if it is changed in sheet one but would like it to be entered into the first
    row with column a blank.
    the reason being is that the full wb has an auto row deletion depending on a given date which would then delete a row in sheet one and because its
    mirrored would leave blank rows in sheet 2.
    Idealy if the data could be copied over and be amended if changed but not be deleted if sheet 1 is cleared that would be spot on.

    Sheet 2 will be a summary profit/loss sheet

    If there is a better ideal rather than mirror data i am open to any sugestions

    thank you in anticipation

    Peter
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    12
    hi
    the reg number would be a uniqe identifiyer could this be used to locate the row to update?

    peter

  3. #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
  •