Consulting

Results 1 to 2 of 2

Thread: Struggling wth VBA, trying to specify paste destination

  1. #1

    Struggling wth VBA, trying to specify paste destination

    I have the following code as part of a larger process. I'm trying to specify the cell where a range of data is to be pasted (CompleteSheetDestRange) and also check/confirm that the rest of the row is blank, however it doesn't seem to work.

    Any help appreciated


    Dim CompleteSheetLastCellOfFirstColumn As Range
    Dim CompleteSheetDestRange As Range
    
    
    
    'FIND LAST CELL WITHIN FIRST COLUMN OF COMPLETE SHEET
       Set CompleteSheetLastCellOfFirstColumn = Sheets("Complete").Range("B" & Rows.Count).End(xlUp)
    
    
    'SET COMPLETE SHEET DESTINATION POINT
       Set CompleteSheetDestRange = CompleteSheetLastCellOfFirstColumn.Offset(1, 0)
    
            'VALIDITY CHECK - CHECK DESTINATION RANGE START ROW IS BLANK
                If Not CompleteSheetDestRange.row Is Nothing Then
                    MsgBox "Complete Sheet Destination Row is not blank, Unable to Transfer Data", 0, "Validity Check Error"
                        Application.Calculation = xlCalculationAutomatic
                            Exit Sub
                    End If

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    'FIND LAST CELL WITHIN //FIRST// Second ("B") COLUMN OF COMPLETE SHEET
       Set CompleteSheetLastCellOfFirstColumn = Sheets("Complete").Cells(Rows.Count, "B").End(xlUp)
    'VALIDITY CHECK - CHECK DESTINATION RANGE START ROW IS BLANK
    If WorksheetFunction.CountA(CompleteSheetDestRange.EntireRow  > 0 Then
    'FIND NEXT TRULY EMPTY ROW
    Do While WorksheetFunction.CountA(CompleteSheetDestRange.EntireRow  > 0
    Set CompleteSheetDestRange = CompleteSheetDestRange.Offset(1, 0)
    Loop
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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