#1   Report Post  
kizzie
 
Posts: n/a
Default loop over columns


Hello,

How do I write a for loop over columns? e.g. For k= A to AA ... is not
working...

thx in advance


--
kizzie
------------------------------------------------------------------------
kizzie's Profile: http://www.excelforum.com/member.php...o&userid=26092
View this thread: http://www.excelforum.com/showthread...hreadid=394203

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

for k = 1 to 27

or ...


with activesheet
for k = .range("a1").column to .range("aa1").column



======
If you're using .cells(), then it can accept either letters or numbers for the
column:

cells(1,3).value = "asdf"
is just as ok as:
cells(1,"C").value = "asdf"



kizzie wrote:

Hello,

How do I write a for loop over columns? e.g. For k= A to AA ... is not
working...

thx in advance

--
kizzie
------------------------------------------------------------------------
kizzie's Profile: http://www.excelforum.com/member.php...o&userid=26092
View this thread: http://www.excelforum.com/showthread...hreadid=394203


--

Dave Peterson
  #3   Report Post  
kizzie
 
Posts: n/a
Default


thx

Cells(Nr).Value = Cells(Nr).Value + Cells(ActiveCell.Rows,
ActiveCell.Columns + 2).Value

Whats wrong with this code? I want to add the value the cell 2 columns
right of the active cell, to the cell named "Nr"

thx


--
kizzie
------------------------------------------------------------------------
kizzie's Profile: http://www.excelforum.com/member.php...o&userid=26092
View this thread: http://www.excelforum.com/showthread...hreadid=394203

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Nr is a range name?

cells("Nr").value _
= cells("Nr").value + cells(activecell.row,activecell.column+2).value

or

cells("Nr").value _
= cells("Nr").value + activecell.offset(0,2).value



kizzie wrote:

thx

Cells(Nr).Value = Cells(Nr).Value + Cells(ActiveCell.Rows,
ActiveCell.Columns + 2).Value

Whats wrong with this code? I want to add the value the cell 2 columns
right of the active cell, to the cell named "Nr"

thx

--
kizzie
------------------------------------------------------------------------
kizzie's Profile: http://www.excelforum.com/member.php...o&userid=26092
View this thread: http://www.excelforum.com/showthread...hreadid=394203


--

Dave Peterson
  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

Oops....if Nr is really a named cell, use this intead.

Range("Nr").value _
= range("Nr").value + cells(activecell.row,activecell.column+2).value

or

range("Nr").value _
= range("Nr").value + activecell.offset(0,2).value



Dave Peterson wrote:

Nr is a range name?

cells("Nr").value _
= cells("Nr").value + cells(activecell.row,activecell.column+2).value

or

cells("Nr").value _
= cells("Nr").value + activecell.offset(0,2).value

kizzie wrote:

thx

Cells(Nr).Value = Cells(Nr).Value + Cells(ActiveCell.Rows,
ActiveCell.Columns + 2).Value

Whats wrong with this code? I want to add the value the cell 2 columns
right of the active cell, to the cell named "Nr"

thx

--
kizzie
------------------------------------------------------------------------
kizzie's Profile: http://www.excelforum.com/member.php...o&userid=26092
View this thread: http://www.excelforum.com/showthread...hreadid=394203


--

Dave Peterson


--

Dave Peterson
Reply
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
Columns FemIce Excel Discussion (Misc queries) 1 September 28th 05 09:29 AM
Arithmetical Mode of Criteria in Multiple Non-Adjacent columns Sam via OfficeKB.com Excel Worksheet Functions 4 July 14th 05 09:15 PM
Hidden Columns in Shared Workbooks Rotary Excel Discussion (Misc queries) 1 July 9th 05 12:28 AM
can't insert columns between columns smooth operator Excel Discussion (Misc queries) 1 May 1st 05 10:53 PM
Removing Near-Duplicate Rows, Leaving Those w/Most Data in Specific Columns foofoo Excel Discussion (Misc queries) 1 April 2nd 05 12:02 AM


All times are GMT +1. The time now is 07:50 AM.

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

About Us

"It's about Microsoft Excel"