View Single Post
  #5   Report Post  
Kleev
 
Posts: n/a
Default How to set variable to cell value in excel macro

You could do something like this:
Dim ws As Worksheet
Dim i As Integer
Dim x As Integer
Set ws = ThisWorkbook.Worksheets("sheet2")
i = ws.Range("c1").Value
x = 1
Do While x < i
ws.Cells(x, 4).Value = x + i
x = x + 1
Loop

"most xlent" wrote:

How do I perform a "do loop" using a cell value as criteria? (i.e.-do while
x < value($c$1). Thanks for your help.