View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default using Subtotals in XL-VBA

Check to see what's in the range before you try the subtotal code.

dim myRng as range

with worksheets("sheet1")
set myrng = .range("a1:e" & .cells(.rows.count,"A").end(xlup).row)
end with

if myrng.rows.count = 1 then
msgbox "just headers--no data"
else
'keep going with your code
end if

I used column A to find out the last used row in that range.

Venky wrote:

I have created a Macro which picks up data from two seperate Access databases
and populates the XL sheets. One of the function of this macro is to pull
data from an Access database and apply subtotals onto to the sheet.

Now this works perfectly fine till the time the information pulled is not
blank.

Now suppose the data pulled has zero records, the Macro stops since there
are nothing to be subtotalled.
How do I fix this. ?


--

Dave Peterson