PC Review


Reply
Thread Tools Rate Thread

Newbie needs macro help Excel 2000

 
 
deb
Guest
Posts: n/a
 
      17th Dec 2004
Greetings,

I need a little bit of assistance in creating a macro in Excel 2000, pc

platform.

I would like the macro to ask for a beginning number and an ending number.

The macro would then populate the corresponding number of rows in column A

(original number) and in column B a number starting with 1 and increasing by

1 until the ending number is met.

For example, the macro asks for beginning number (I would enter 123) and

ending number is 130: cell A1 would contain 123, cell A2 contains 124, cell

A3 contains 125, cell A4 contains 126, cell A5 contains 127, cell A6

contains 128, cell A7 contains 129, cell A8 contains 130 (eight rows); cell

B1 would contain 1, cell B2 would contain 2...cell B8 would contain 8.

Is my question clear?

Any and all help/suggestions would be greatly appreciated.

TIA.

Dave


 
Reply With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      17th Dec 2004
One way:


Public Sub FillIntegralSeries()
Const sTITLE As String = "Fill Series"
Dim vResult1 As Variant
Dim vResult2 As Variant
Dim nNumRows As Long
Dim bValid As Boolean
vResult1 = Application.InputBox( _
Prompt:="Enter starting number:", _
Default:=1, _
Title:=sTITLE, _
Type:=1)
'Check if user cancelled
If TypeName(vResult1) = "Boolean" Then Exit Sub
Do
bValid = True
vResult2 = Application.InputBox( _
Prompt:="Enter ending number (greater than " & _
vResult1 & "):", _
Default:=vResult1 + 1, _
Title:=sTITLE, _
Type:=1)
'Check if user cancelled
If TypeName(vResult2) = "Boolean" Then Exit Sub
nNumRows = vResult2 - vResult1 + 1
If nNumRows > ActiveSheet.Rows.Count Then
bValid = False
MsgBox "Ending value too large"
ElseIf nNumRows < 0 Then
bValid = False
MsgBox "Ending value must be less than start value"
End If
Loop Until bValid
With Range("A1:B1")
.Item(1).Value = vResult1
.Item(2).Value = 1
.AutoFill _
Destination:=.Resize(nNumRows, 2), _
Type:=xlFillSeries
End With
End Sub




In article <(E-Mail Removed)>,
"deb" <(E-Mail Removed)> wrote:

> Greetings,
>
> I need a little bit of assistance in creating a macro in Excel 2000, pc
>
> platform.
>
> I would like the macro to ask for a beginning number and an ending number.
>
> The macro would then populate the corresponding number of rows in column A
>
> (original number) and in column B a number starting with 1 and increasing by
>
> 1 until the ending number is met.
>
> For example, the macro asks for beginning number (I would enter 123) and
>
> ending number is 130: cell A1 would contain 123, cell A2 contains 124, cell
>
> A3 contains 125, cell A4 contains 126, cell A5 contains 127, cell A6
>
> contains 128, cell A7 contains 129, cell A8 contains 130 (eight rows); cell
>
> B1 would contain 1, cell B2 would contain 2...cell B8 would contain 8.
>
> Is my question clear?
>
> Any and all help/suggestions would be greatly appreciated.
>
> TIA.
>
> Dave

 
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
Excel 2000 Newbie Questions sherlock62 Microsoft Excel Discussion 2 11th Dec 2007 09:56 AM
Extract macro text out of Excel (Newbie) =?Utf-8?B?RGF2aWQgUm9zcw==?= Microsoft Excel Programming 2 25th May 2006 05:57 AM
Please help a newbie with an excel vba macro relating to comments. =?Utf-8?B?enVsZmVyNw==?= Microsoft Excel Misc 8 19th May 2006 11:40 PM
Newbie needs macro help Excel 2000 deb Microsoft Excel Discussion 5 17th Dec 2004 08:37 PM
Newbie - populate (macro) GUI from Excel cells Bill Burke Microsoft Excel Programming 2 3rd Apr 2004 08:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:35 AM.