![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Apr 2008
Posts: 1
OS: Windows xp
|
Need VisualBasic help please...
I am certain that this is child's play for most of you, but only having programmed in Perl and SQL (and it's been 3 years) I simply can't figure out how to make this happen: I have one column of discontinuous data in an Excel Spreadsheet. I need to select each cell in a continuous block of data and add the subtotal to the next empty cell. And repeat with each block of data down that column.
Thanks in advance for any help anyone can provide! |
|
|
|
|
|
#2 (permalink) |
|
Registered User
Join Date: Jan 2008
Location: Harpers Ferry, WV
Posts: 244
OS: OS X 10.4.x
|
Re: Need VisualBasic help please...
Try this.
Code:
Public Function SubTotals()
Dim LastCell As Integer
Dim lp As Integer
Dim FirstCell As Integer
LastCell = Selection.SpecialCells(xlCellTypeLastCell).Row
Range("A1").Select
For lp = 1 To LastCell + 1
If Range("A" & lp) = "" And FirstCell > 0 Then
Range("A" & lp).FormulaR1C1 = "=SUM(R[-" & lp - FirstCell & "] C:R[-1]C)"
FirstCell = 0
Else
If Range("A" & lp) <> "" And FirstCell = 0 Then FirstCell = lp
End If
Next lp
End Function
|
|
|
|
![]() |
| Thread Tools | |
|
|