A
archerokie
Hi all. This is my first post here but have gotten valuable info already by
browsing posts.
I need to determine if a row is blank. I found the CountA function and it
works well, returning 0 if the row is blank. However, I have had trouble in
Excel automation in the past by not having valid or properly qualified
references to Excel objects.
The following code (part of a bigger sub) works fine and does what I need
except for one thing, when the procedure is complete, the Excel object won't
close. Can anyone tell me where my improper reference may be?
(if I comment out the rows with CountA, the Excel object closes)
Thanks.
Keith
With .Sheets(strSheetStoreName)
xlApp.ActiveSheet.ResetAllPageBreaks
r = 57
Do Until r > intLastRow 'outer loop
Do Until xlApp.CountA(Rows(r)) = 0 'inner loop
If xlApp.CountA(Rows(r)) <> 0 Then r = r - 1
Loop 'inner loop
If xlApp.WorksheetFunction.CountA(Rows(r)) = 0 Then .HPageBreaks.Add
Before:=.Range("a" & r)
r = r + 57
Loop 'outer loop
End With '.sheets(strsheetstorename)
browsing posts.
I need to determine if a row is blank. I found the CountA function and it
works well, returning 0 if the row is blank. However, I have had trouble in
Excel automation in the past by not having valid or properly qualified
references to Excel objects.
The following code (part of a bigger sub) works fine and does what I need
except for one thing, when the procedure is complete, the Excel object won't
close. Can anyone tell me where my improper reference may be?
(if I comment out the rows with CountA, the Excel object closes)
Thanks.
Keith
With .Sheets(strSheetStoreName)
xlApp.ActiveSheet.ResetAllPageBreaks
r = 57
Do Until r > intLastRow 'outer loop
Do Until xlApp.CountA(Rows(r)) = 0 'inner loop
If xlApp.CountA(Rows(r)) <> 0 Then r = r - 1
Loop 'inner loop
If xlApp.WorksheetFunction.CountA(Rows(r)) = 0 Then .HPageBreaks.Add
Before:=.Range("a" & r)
r = r + 57
Loop 'outer loop
End With '.sheets(strsheetstorename)