Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For loop with non consecutive number

Hi guys!

I need some help ! I want to know if its possible to loop wit
different numbers like that:

CellArray = Array(1, 2, 5, 10)

'the i should take 1, after 2, after 5, after 10

Worksheets("Mold base").Activate
LargMoule = Range("c2").Value
LongMoule = Range("d2").Value
LargeurParallele = Range("o47").Value
ActiveCell = Range("d17").Activate
ActiveCell.Value = "Largeur"

For i = 1 To UBound(CellArray)

If IsEmpty(ActiveCell.Offset(i, -1)) = False Then
ActiveCell.Offset(i, 0) = LargMoule
ActiveCell.Offset(i, 1) = LongMoule
Largeur(i) = LargMoule
Longueur(i) = LongMoule
End If

thanks a lo

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For loop with non consecutive number

you can suggest something different from looping with "for

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default For loop with non consecutive number

Hi Zapatista66,

As an example:

Sub nnn()
Dim i As Long
Dim cellarray As Variant

cellarray = Array(1, 2, 5, 10)

For i = LBound(cellarray) To UBound(cellarray)
MsgBox cellarray(i)
Next

End Sub

---
Regards,
Norman



"zapatista66 " wrote in message
...
you can suggest something different from looping with "for"


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default For loop with non consecutive number

if equally spaced

for i = 1 to 10*3 step 3

Next i

--
Regards,
Tom Ogilvy

"zapatista66 " wrote in message
...
you can suggest something different from looping with "for"


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default For loop with non consecutive number

zapatista66 < wrote:

Hi guys!

I need some help ! I want to know if its possible to loop with
different numbers like that:

CellArray = Array(1, 2, 5, 10)

'the i should take 1, after 2, after 5, after 10

Worksheets("Mold base").Activate
LargMoule = Range("c2").Value
LongMoule = Range("d2").Value
LargeurParallele = Range("o47").Value
ActiveCell = Range("d17").Activate
ActiveCell.Value = "Largeur"

For i = 1 To UBound(CellArray)

If IsEmpty(ActiveCell.Offset(i, -1)) = False Then
ActiveCell.Offset(i, 0) = LargMoule
ActiveCell.Offset(i, 1) = LongMoule
Largeur(i) = LargMoule
Longueur(i) = LongMoule
End If

thanks a lot


---
Message posted from http://www.ExcelForum.com/

Assuming that CellArray is a 1-based array, just substitute CellArray(i)
for each i in your code.

Alan Beban


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For loop with non consecutive number

Thanks all of U !
It's done

--
Message posted from http://www.ExcelForum.com

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
Counting the Number of Consecutive Ranges allan2005CL Excel Worksheet Functions 0 August 22nd 10 08:46 PM
Excel and consecutive number Shadowkiller361 Excel Worksheet Functions 2 May 3rd 10 10:17 PM
how to consecutive number same worksheet Bob New Users to Excel 1 February 11th 10 07:32 PM
Count Consecutive string of same number andy Excel Worksheet Functions 6 December 29th 09 03:48 AM
How do i automaticaly number consecutive forms Stan O. Terry Excel Worksheet Functions 2 February 8th 07 03:02 AM


All times are GMT +1. The time now is 12:27 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"