PC Review


Reply
Thread Tools Rate Thread

Auto Increment Number

 
 
E_Dirksen
Guest
Posts: n/a
 
      24th Jun 2008
Hello,

I've been trying to create a Macro that when a button is clicked, the cell
will place a number in the box and then move down one row in the same column.
I can ove the cell down a row but I need to be able to automatically
incrment the number by 1 each time. Can anyone help?
 
Reply With Quote
 
 
 
 
Thomas [PBD]
Guest
Posts: n/a
 
      24th Jun 2008
E_Dirksen,

I have created a macro for you. Please place this into a module inside of
VBA and run the Macro (Tools>Macro>Number_Range).
It can be amended to start at the active cell, but currently it will ask you
what Range and then what you want the starting number to be.

Sub Number_Range()
Dim xlssheet As Excel.Worksheet
Dim x As Long
Dim rng As String
Dim y As Long
Dim z As Long

Set xlssheet = Excel.ActiveSheet
x = 1
rng = InputBox("Enter Range (i.e. A1:A5)", "Range")
y = InputBox("Enter Starting Value", "Start")


xlssheet.Range(rng).Select
z = Selection.Cells.Count

For x = 1 To z
xlssheet.Cells(x, 1).Value = y
y = y + 1
Next

End Sub

"E_Dirksen" wrote:

> Hello,
>
> I've been trying to create a Macro that when a button is clicked, the cell
> will place a number in the box and then move down one row in the same column.
> I can ove the cell down a row but I need to be able to automatically
> incrment the number by 1 each time. Can anyone help?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Increment Number ChoonBoy Microsoft Access Form Coding 6 10th Jul 2009 12:15 PM
Re: How to generate a auto number or increment number strive4peace Microsoft Access Queries 1 19th Apr 2008 10:20 PM
Auto Increment Number =?Utf-8?B?UnVzdHk=?= Microsoft Access 4 10th Jul 2006 12:13 PM
Auto Number increment by 2 Tracey Microsoft Access Database Table Design 0 9th Sep 2003 09:56 AM
Auto Increment a number field jaycee Microsoft Access Forms 0 31st Jul 2003 12:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:38 PM.