VBA=Excel cell

L

LiAD

Good Evening,

I have a very simple VBA question as I know completely zero about it.

I have a line of code for a print macro, part of which details how many
copies to print;

Sub PrintEm()
Dim i As Integer
For i = 1 To 10

I would like the value 10 to come from a cell in excel, BK3, therefore the
user does not need to access VBA to change how many copies are needed. I
have tried various gestimates of how to do this with no luck.

Is it possible to have an =BK3 type formula in place of the 10?

Thanks for your help
 
P

Per Jessen

Hi

Try this:

Sub PrintEm()
Dim i As Integer
Dim MyNum As Integer

MyNum = Worksheets("Sheet1").Range("BK3").Value
For i = 1 To MyNum

Regards,
Per
 
F

FSt1

hi
something like this might work...
Sub printem()
Dim i As Integer
Dim nc As Long
nc = Range("A1").Value 'change address to suit
For i = 1 To nc
MsgBox nc 'test purposes only
'your other code here
Next i
End Sub

regards
FSt1
 
C

Chip Pearson

Try something like

For i = 1 To Worksheets("Sheet1").Range("BK3").Value

Change the sheet name to the appropriate sheet name.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Top