Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default VB Macro statemenent in Excel

Hi,
I have multiple lines of code in a macro of the following
format. As you can see some of the cell references
increment by a single digit (up to 103) and everything
else remains the same:

Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells(506,
2)), 1) = Sheet24.Cells(4, 1)
Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells
(506, 2)), 2) = Sheet24.Cells(4, 2)
Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells
(506, 2)), 3) = Sheet24.Cells(4, 3)


I've been trying to use a while do loop where the
incrementing number is a variable but for some reason a
number won't assign to my count variable.

The format of the while do loop is:

count=1
while (count<103) do

Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells(506,
2)), Count) = Sheet24.Cells(4, Count)
count=count+1

Loop


Is this correct? When I run debug it shows count to
equal null. Am I doing something incorrect?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default VB Macro statemenent in Excel

Change it to a while-wend loop

While count < 103
<statement
count = count + 1
Wend

or use a for-next loop,

Dim count as Long
For count = 1 to 102
< statement
Next count

Cheers
Nigel

wrote in message
...
Hi,
I have multiple lines of code in a macro of the following
format. As you can see some of the cell references
increment by a single digit (up to 103) and everything
else remains the same:

Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells(506,
2)), 1) = Sheet24.Cells(4, 1)
Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells
(506, 2)), 2) = Sheet24.Cells(4, 2)
Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells
(506, 2)), 3) = Sheet24.Cells(4, 3)


I've been trying to use a while do loop where the
incrementing number is a variable but for some reason a
number won't assign to my count variable.

The format of the while do loop is:

count=1
while (count<103) do

Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells(506,
2)), Count) = Sheet24.Cells(4, Count)
count=count+1

Loop


Is this correct? When I run debug it shows count to
equal null. Am I doing something incorrect?

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default VB Macro statemenent in Excel

Champion that worked a treat....

thanks


-----Original Message-----
Change it to a while-wend loop

While count < 103
<statement
count = count + 1
Wend

or use a for-next loop,

Dim count as Long
For count = 1 to 102
< statement
Next count

Cheers
Nigel

wrote in message
...
Hi,
I have multiple lines of code in a macro of the

following
format. As you can see some of the cell references
increment by a single digit (up to 103) and everything
else remains the same:

Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells

(506,
2)), 1) = Sheet24.Cells(4, 1)
Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells
(506, 2)), 2) = Sheet24.Cells(4, 2)
Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells
(506, 2)), 3) = Sheet24.Cells(4, 3)


I've been trying to use a while do loop where the
incrementing number is a variable but for some reason a
number won't assign to my count variable.

The format of the while do loop is:

count=1
while (count<103) do

Sheet22.Cells((Sheet1.Cells(502, 11) + Sheet1.Cells

(506,
2)), Count) = Sheet24.Cells(4, Count)
count=count+1

Loop


Is this correct? When I run debug it shows count to
equal null. Am I doing something incorrect?

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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM


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

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"