Using data in active cell in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am currently working on writing my first VBA program, but am having
trouble determing how to reference a value in the active cell of the
worksheet. I want the value in the active cell to be passed to
"TimeBlocks"-- which will then tell the computer the # of times to loop
through the statement.

Any help would be greatly appreciated.

Thanks,
Liz

This is what i have so far:

Sub Macro3()
'
' Macro3 Macro
'

'
Dim counter As Integer
Dim TimeBlocks As Integer


Set TimeBlocks = ActiveCell.Value

ActiveCell.Offset(1, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = "v"

For counter = 1 To TimeBlocks
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "v"
Next counter

End Sub
 
Hi Liz,

Try this..

Dim counter As Integer
Dim TimeBlocks As Integer

Set TimeBlocks = ActiveCell.Value
Range("A1").Select

TIMEBLOCKS = activecell.value ''this assumes that the number of times to run
the loop is in cell A1

do until counter = timeblocks
'''put in whatever you want to happen here
counter = counter + 1
loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top