Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Biomed
 
Posts: n/a
Default Using For - Next Loops in VB

Excel 2000 SR-1

I am trying to write a VB code using a For - Next statement to calcualate
cells.
The basic satement is:

For X = 1 to 7
[A(x)] = {Calcualtion} ' Where A=Column and X = Row
Next X

Is there a correct way in VB code? This would greatly reduce the code I
would have to write otherwise.
  #2   Report Post  
Duke Carey
 
Posts: n/a
Default

if you want to put a VALUE in the cell, use something like this
==============================
Sub PutValues()
Dim ws As Worksheet
Dim x As Integer

Set ws = ActiveSheet
With ws
For x = 1 To 7
.Cells(x, 1) = x
Next x
End With
End Sub
==============================

If you want to insert FORMULAS, use something like
==============================
Sub PutFormulas()
Dim ws As Worksheet
Dim x As Integer

With ws
For x = 1 To 7
.Cells(x, 1).Formula = "=2*" & x
Next x
End With
End Sub
==============================
"Biomed" wrote:

Excel 2000 SR-1

I am trying to write a VB code using a For - Next statement to calcualate
cells.
The basic satement is:

For X = 1 to 7
[A(x)] = {Calcualtion} ' Where A=Column and X = Row
Next X

Is there a correct way in VB code? This would greatly reduce the code I
would have to write otherwise.

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



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