Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to set a variable in Excel and loop


Dim varCount As String
VarCount = 5
Dim I As Integer
For I = 1 To 10 Step 1
Range("B1").Select
ActiveCell.FormulaR1C1 = "=Sheet1!R[VarCount]C"
Range("C1").Select
ActiveCell.FormulaR1C1 = "=Sheet1!R[VarCOunt]C"
VarCount = Varcount + 1
Range("D1").Select
Next I
End Sub

Well I hope that for the pro's here this is clear and know what th
answer is, well just to explain, in sheet Sheet1 starting on collum B
down there are names which i want to "put" in another sheet at cell B
and then print this page, then the B2 at sheet1, then B3, so to make
long story short, the vat Varcount must be a number value, if i put
at where VarCount is the macro will work but print the value o
Sheet1!R[1] ten times :)

So the outcome must be that it's Sheet1!R[1], Sheet1!R[2], Sheet1!R[3
ect.

Hope somebody here has an answer.

Thanks

--
frankep
-----------------------------------------------------------------------
frankeps's Profile: http://www.excelforum.com/member.php...fo&userid=1571
View this thread: http://www.excelforum.com/showthread.php?threadid=27238

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to set a variable in Excel and loop

Frank,

Don't follow the explanation at all as I don't see any other sheet, where I
is used, how VarCount equates to your example, etc., so this is a real long
shot

Dim varCount As String
VarCount = 5
Dim I As Integer
For I = 1 To 10 Step 1
Range("B" & I).FormulaR1C1 = "=Sheet1!R[" & VarCount & "]C"
Range("C" & I).FormulaR1C1 = "=Sheet1!R[" & VarCount & "]C"
VarCount = Varcount + 1
Next I
End Sub


--

HTH

RP

"frankeps" wrote in message
...

Dim varCount As String
VarCount = 5
Dim I As Integer
For I = 1 To 10 Step 1
Range("B1").Select
ActiveCell.FormulaR1C1 = "=Sheet1!R[VarCount]C"
Range("C1").Select
ActiveCell.FormulaR1C1 = "=Sheet1!R[VarCOunt]C"
VarCount = Varcount + 1
Range("D1").Select
Next I
End Sub

Well I hope that for the pro's here this is clear and know what the
answer is, well just to explain, in sheet Sheet1 starting on collum B1
down there are names which i want to "put" in another sheet at cell B1
and then print this page, then the B2 at sheet1, then B3, so to make a
long story short, the vat Varcount must be a number value, if i put 1
at where VarCount is the macro will work but print the value of
Sheet1!R[1] ten times :)

So the outcome must be that it's Sheet1!R[1], Sheet1!R[2], Sheet1!R[3]
ect.

Hope somebody here has an answer.

Thanks.


--
frankeps
------------------------------------------------------------------------
frankeps's Profile:

http://www.excelforum.com/member.php...o&userid=15710
View this thread: http://www.excelforum.com/showthread...hreadid=272381



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default How to set a variable in Excel and loop

Hi
you don't have a print routine by now. dow you mean:
Dim varCount As String
VarCount = 5
Dim I As Integer
For I = 1 To 10 Step 1
Range("B1").FormulaR1C1 = "=Sheet1!R[" & VarCount & "]C"
Range("C1").FormulaR1C1 "=Sheet1!R[" & VarCount & "]C"
VarCount = Varcount + 1
activesheet.printout
Next I
End Sub



"frankeps" wrote:


Dim varCount As String
VarCount = 5
Dim I As Integer
For I = 1 To 10 Step 1
Range("B1").Select
ActiveCell.FormulaR1C1 = "=Sheet1!R[VarCount]C"
Range("C1").Select
ActiveCell.FormulaR1C1 = "=Sheet1!R[VarCOunt]C"
VarCount = Varcount + 1
Range("D1").Select
Next I
End Sub

Well I hope that for the pro's here this is clear and know what the
answer is, well just to explain, in sheet Sheet1 starting on collum B1
down there are names which i want to "put" in another sheet at cell B1
and then print this page, then the B2 at sheet1, then B3, so to make a
long story short, the vat Varcount must be a number value, if i put 1
at where VarCount is the macro will work but print the value of
Sheet1!R[1] ten times :)

So the outcome must be that it's Sheet1!R[1], Sheet1!R[2], Sheet1!R[3]
ect.

Hope somebody here has an answer.

Thanks.


--
frankeps
------------------------------------------------------------------------
frankeps's Profile: http://www.excelforum.com/member.php...o&userid=15710
View this thread: http://www.excelforum.com/showthread...hreadid=272381


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
Loop with variable name? Mike Excel Discussion (Misc queries) 6 April 25th 09 05:12 AM
Creating a formula using the loop variable Spector[_2_] Excel Programming 1 October 22nd 04 10:10 PM
Creating a formula using the loop variable Spector Excel Programming 1 October 22nd 04 07:42 PM
Excel VBA Loop & Variable Reference Carolyn[_4_] Excel Programming 2 October 15th 04 08:30 PM
Re-assigning the value of a variable for a for loop from Mike Berry Excel Programming 1 July 16th 03 02:41 PM


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