Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Why doesn't this simple macro work

Sub MyNext()
For X = 1 To 10 Step 1
For Y = 1 To 40 Step 4
Range("A" & Y) = X & "Words"
Next Y
Next X
End Sub
Y iterates OK but X never gets a look in??
--
donwb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Why doesn't this simple macro work

What are you expecting it to do because (probably infuriatingly for you)it
is doing ecactly what you are telling it to do which is

Write "1WORDS" to a1, A5 down to A37
The 1 comes from the X loop and words from the Y loop
The macrow then overwrites each of these cells with 2Words, 3words etc up to
10Words.

Mike

"donbowyer" wrote:

Sub MyNext()
For X = 1 To 10 Step 1
For Y = 1 To 40 Step 4
Range("A" & Y) = X & "Words"
Next Y
Next X
End Sub
Y iterates OK but X never gets a look in??
--
donwb

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Why doesn't this simple macro work

Hi Mike
Yes I agree.
What I would like it to do is put "1Word" in Cell A1, then
"2Word" in cell A5, then "3Word" in A9 etc
Don
--
donwb


"Mike H" wrote:

What are you expecting it to do because (probably infuriatingly for you)it
is doing ecactly what you are telling it to do which is

Write "1WORDS" to a1, A5 down to A37
The 1 comes from the X loop and words from the Y loop
The macrow then overwrites each of these cells with 2Words, 3words etc up to
10Words.

Mike

"donbowyer" wrote:

Sub MyNext()
For X = 1 To 10 Step 1
For Y = 1 To 40 Step 4
Range("A" & Y) = X & "Words"
Next Y
Next X
End Sub
Y iterates OK but X never gets a look in??
--
donwb

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Why doesn't this simple macro work

Try this

Sub MyNext()
x = 1
For Y = 1 To 40 Step 4
Range("A" & Y) = x & "Words"
x = x + 1
Next
End Sub

Mike

"donbowyer" wrote:

Hi Mike
Yes I agree.
What I would like it to do is put "1Word" in Cell A1, then
"2Word" in cell A5, then "3Word" in A9 etc
Don
--
donwb


"Mike H" wrote:

What are you expecting it to do because (probably infuriatingly for you)it
is doing ecactly what you are telling it to do which is

Write "1WORDS" to a1, A5 down to A37
The 1 comes from the X loop and words from the Y loop
The macrow then overwrites each of these cells with 2Words, 3words etc up to
10Words.

Mike

"donbowyer" wrote:

Sub MyNext()
For X = 1 To 10 Step 1
For Y = 1 To 40 Step 4
Range("A" & Y) = X & "Words"
Next Y
Next X
End Sub
Y iterates OK but X never gets a look in??
--
donwb

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Why doesn't this simple macro work

Which of course works.
Many thanks - the simple answer was elududing me
Don
--
donwb


"Mike H" wrote:

Try this

Sub MyNext()
x = 1
For Y = 1 To 40 Step 4
Range("A" & Y) = x & "Words"
x = x + 1
Next
End Sub

Mike

"donbowyer" wrote:

Hi Mike
Yes I agree.
What I would like it to do is put "1Word" in Cell A1, then
"2Word" in cell A5, then "3Word" in A9 etc
Don
--
donwb


"Mike H" wrote:

What are you expecting it to do because (probably infuriatingly for you)it
is doing ecactly what you are telling it to do which is

Write "1WORDS" to a1, A5 down to A37
The 1 comes from the X loop and words from the Y loop
The macrow then overwrites each of these cells with 2Words, 3words etc up to
10Words.

Mike

"donbowyer" wrote:

Sub MyNext()
For X = 1 To 10 Step 1
For Y = 1 To 40 Step 4
Range("A" & Y) = X & "Words"
Next Y
Next X
End Sub
Y iterates OK but X never gets a look in??
--
donwb



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Why doesn't this simple macro work

Your welcome

"donbowyer" wrote:

Which of course works.
Many thanks - the simple answer was elududing me
Don
--
donwb


"Mike H" wrote:

Try this

Sub MyNext()
x = 1
For Y = 1 To 40 Step 4
Range("A" & Y) = x & "Words"
x = x + 1
Next
End Sub

Mike

"donbowyer" wrote:

Hi Mike
Yes I agree.
What I would like it to do is put "1Word" in Cell A1, then
"2Word" in cell A5, then "3Word" in A9 etc
Don
--
donwb


"Mike H" wrote:

What are you expecting it to do because (probably infuriatingly for you)it
is doing ecactly what you are telling it to do which is

Write "1WORDS" to a1, A5 down to A37
The 1 comes from the X loop and words from the Y loop
The macrow then overwrites each of these cells with 2Words, 3words etc up to
10Words.

Mike

"donbowyer" wrote:

Sub MyNext()
For X = 1 To 10 Step 1
For Y = 1 To 40 Step 4
Range("A" & Y) = X & "Words"
Next Y
Next X
End Sub
Y iterates OK but X never gets a look in??
--
donwb

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
why doesn't this simple macro work in excel 2007? ManhattanRebel Excel Discussion (Misc queries) 8 July 19th 08 06:37 PM
So simple, but I can't get it to work hmsawyer Excel Discussion (Misc queries) 4 April 5th 08 07:58 AM
Why doesn't my simple macro work? Tibbs[_3_] Excel Programming 5 March 1st 06 02:56 PM
Simple Macro, works in Excel 2002, 2003 but won't work in 2000 DJA[_2_] Excel Programming 5 September 28th 05 05:10 PM
Why this simple macro doesn't work? 71marco71[_8_] Excel Programming 2 February 6th 04 06:53 PM


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