View Single Post
 
Old 05-23-2016, 05:15 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gbrew584 View Post
Is there a way I test just one section of my code? Sorry I'm getting a little off the topic.
That's fairly basic. Just use something like:
Code:
Sub Test()
Dim xlApp As Object, xlbook As Object, LastRow As Long
Const xlpart = 2
Const xlbyrows = 1
Const xlprevious = 2
Const xlformulas = 5
Set xlApp = CreateObject("Excel.Application")
Set xlbook = xlApp.workbooks.Add
xlbook.Sheets(1).Range("A1").PasteSpecial
With xlbook.Sheets(1)
    If xlApp.WorksheetFunction.CountA(.Cells) <> 0 Then
        LastRow = .Cells.Find(What:="*", _
                      After:=.Range("A1"), _
                      Lookat:=xlpart, _
                      LookIn:=xlformulas, _
                      SearchOrder:=xlbyrows, _
                      SearchDirection:=xlprevious, _
                      MatchCase:=False).Row
     Else
         LastRow = 1
     End If
  End With
  MsgBox LastRow
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote