Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default loop through columns (using for-loop)

Hello,

I now discovered the syntax to loop through rows:
example:

For i = 3 To 20
If Range("A" & i).Value = "" Then
Range("A" & 1).Copy Destination:=Range("A" & i)
End If
Next i

How can I use the same method for scrolling trough columns?
How can I get to column B using something like "A+1"

extra question: why is the "Next i" placed behind the for-loop? Isn't
it placed in the for-loop with other languages?

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default loop through columns (using for-loop)

On 23 Nov., 20:08, Kurt wrote:
Hello,

I now discovered the syntax to loop through rows:
example:

For i = 3 To 20
If Range("A" & i).Value = "" Then
Range("A" & 1).Copy Destination:=Range("A" & i)
End If
Next i

How can I use the same method for scrolling trough columns?
How can I get to column B using something like "A+1"

extra question: why is the "Next i" placed behind the for-loop? Isn't
it placed in the for-loop with other languages?

Thanks in advance!


Hi Kurt

MyRow = 1
For i = 3 To 20
If Cells(MyRow, i).Value = "" Then Cells(MyRow, i) = Cells(MyRow,
1).Value
Next

Regards,

Per
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default loop through columns (using for-loop)

Here is a place to answer some questions:

http://www.excel-vba.com/excel-vba-contents.htm

Just start at the beginning and work your way through. It explains a lot of
the basics and gives examples..


"Kurt" wrote:

Hello,

I now discovered the syntax to loop through rows:
example:

For i = 3 To 20
If Range("A" & i).Value = "" Then
Range("A" & 1).Copy Destination:=Range("A" & i)
End If
Next i

How can I use the same method for scrolling trough columns?
How can I get to column B using something like "A+1"

extra question: why is the "Next i" placed behind the for-loop? Isn't
it placed in the for-loop with other languages?

Thanks in advance!

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
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 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 04:37 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"