LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Problem with a loop and column references

Part way there.

Twelve groups of 4 columns with a blank column between each group and a two column group at the end.

Each column in each group will have the same number of rows and that number will change often.

Each group will have a different number of rows from the other groups but again always the same number of rows within the group.

The code below puts the sum formula properly at the end of each column and in each group (except the two column group which I will probably write a separate line bit code to take care of them).

The LastRow is giving me fits as I need it to refer to each group as the For iI loop does it looping.

Second major problem is getting the formula to refer to proper columns as it loops. As it is, it refers only to the first group.

The commented out LastRow works but only refers to the first group.

Thanks,
Howard

Sub SumMyCols()

Dim i As Long
Dim LastRow As Long, myCol As Long, iI As Long
Dim sumRng As Range

'("AB:AE, AG:AJ, AL:AO, AQ:AT, AV:AY, BA:BD, BF:BI, BK:BN, BP:BS, BU:BX, BZ:CC, CE:CH, CJ:CK")

'LastRow = Range("AB:AE").Find(What:="*", after:=[ab8], _
searchorder:=xlByRows, _
searchdirection:=xlPrevious).Row

' MsgBox LastRow


For iI = 28 To 86

LastRow = Range(Cells(9, iI)).Find(What:="*", after:=Range(Cells(8, iI)), _
searchorder:=xlByRows, _
searchdirection:=xlPrevious).Row

Cells(LastRow + 2, iI).Resize(1, 4) = Application.WorksheetFunction.Sum(Range("AB9:AB" & LastRow))
iI = iI + 4

Next 'iI

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop returns only one value, does not loop & an assignment to columnhow-to problem. Howard Excel Programming 26 April 4th 13 12:01 AM
Permanently link formula references to Column Names and not Column Cell Numbers Excel Dumbo Excel Discussion (Misc queries) 1 February 21st 13 03:23 AM
how to change column references, while filling down another column bclancy12 Excel Discussion (Misc queries) 1 June 7th 06 04:13 PM
column loop problem?? Mike Excel Programming 2 October 20th 05 05:47 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


All times are GMT +1. The time now is 02:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"