Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default VBA=Excel cell

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default VBA=Excel cell

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

"LiAD" skrev i meddelelsen
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default VBA=Excel cell

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

"LiAD" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA=Excel cell


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)





On Sat, 10 Jan 2009 12:15:00 -0800, LiAD
wrote:

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

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
Excel Select All Visible Merged cell then Spread Cell Data rtwiss via OfficeKB.com Excel Programming 5 October 7th 08 04:33 PM
Excel:Swap cell contents-including cell groups-betwen 2 locations Rob R Excel Discussion (Misc queries) 0 February 6th 08 11:13 PM
copy excel cell to cell in word table using excel macro jthurnwps Excel Discussion (Misc queries) 0 July 21st 06 07:11 PM
Can Excel 2003 cell link carry with it the source cell format? tom Excel Discussion (Misc queries) 2 July 14th 06 06:14 AM
If data added to Excel cell it automatically make's another cell equal zero [email protected] Excel Programming 1 October 19th 05 06:00 PM


All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"