ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through columns (https://www.excelbanter.com/excel-programming/319890-looping-through-columns.html)

Teresa

Looping through columns
 
Hi, would like to do the following operation with columns C:H
and then columns K:M,

Im missing a couple of lines in my code below which will loop through
necessary cols, any help is much appreciated

sub()

Dim intNumRows As Integer, c As Variant, lngCellTotal As Long
Dim x As Integer

intNumRows = Cells(50, "c").End(xlUp).Row
With Range("c" & intNumRows + 1)
.Borders(xlEdgeTop).Weight = xlMedium

End With
For Each c In Range("c1", "c" & intNumRows)
lngCellTotal = lngCellTotal + c.Value
Next
Range("c" & intNumRows + 1) = lngCellTotal

end sub



Tom Ogilvy

Looping through columns
 
See your previous post. You can adjust the code there to do what you want.

--
Regards,
Tom Ogilvy

"teresa" wrote in message
...
Hi, would like to do the following operation with columns C:H
and then columns K:M,

Im missing a couple of lines in my code below which will loop through
necessary cols, any help is much appreciated

sub()

Dim intNumRows As Integer, c As Variant, lngCellTotal As Long
Dim x As Integer

intNumRows = Cells(50, "c").End(xlUp).Row
With Range("c" & intNumRows + 1)
.Borders(xlEdgeTop).Weight = xlMedium

End With
For Each c In Range("c1", "c" & intNumRows)
lngCellTotal = lngCellTotal + c.Value
Next
Range("c" & intNumRows + 1) = lngCellTotal

end sub





Bob Phillips[_6_]

Looping through columns
 
Where has this digressed from B to I?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"teresa" wrote in message
...
Hi, would like to do the following operation with columns C:H
and then columns K:M,

Im missing a couple of lines in my code below which will loop through
necessary cols, any help is much appreciated

sub()

Dim intNumRows As Integer, c As Variant, lngCellTotal As Long
Dim x As Integer

intNumRows = Cells(50, "c").End(xlUp).Row
With Range("c" & intNumRows + 1)
.Borders(xlEdgeTop).Weight = xlMedium

End With
For Each c In Range("c1", "c" & intNumRows)
lngCellTotal = lngCellTotal + c.Value
Next
Range("c" & intNumRows + 1) = lngCellTotal

end sub






All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com