subtotal problem

  • Thread starter Thread starter pcscsr
  • Start date Start date
P

pcscsr

I have the following code which works well when I run the program fro
the "worksheet" module. However, if I try to run the main program fro
the "userform" module when I make my selections from my listbox, it doe
not work. Can someone help me with this..?

Sub sumthem()

dim i as long
dim rsum as single

For i = 1 to range("d800").end(xlup).row + 1
rsum = rnum + Range ("D" & i).value
If Range ("D" + 1).value = "" And Range (D" &
i + 1).Value = "" Then
Range("D" & i).value = rsum
rsum = 0
End if
next
end su
 
-Hi,

why don't you try:-

Sub sumthem()

dim i as long
dim rsum as single

For i = 1 to activesheet.range("d800").end(xlup).row + 1
rsum = rnum + activesheet.Range ("D" & i).value
If activesheet.Range ("D" + 1).value = "" activesheet.And Range (D" &
i + 1).Value = "" Then
activesheet.Range("D" & i).value = rsum
rsum = 0
End if
next
end sub

-If this does not solve the problem replace "activesheet" b
Worksheets("ref"), where "ref" is an appropriate reference to th
worksheet you intend to process.

Let me know in case this does not work out,

urs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top