AutoFill a Column

pdieppa

New Member
Joined
Nov 30, 2005
Messages
4
Hi there

This is my first post; hopefully it will not be my last as I see there is very good information here!

I have a simple request from one our remote offices.

C2 Contains either a single or three character letter
D2 contains a number
E2 contains a number

I need to combine the letter(s) with the number (C2 & D2) to become one and autofill A column with sequential numbers up to the value of E2.

Example:

If I type E in C2 and 1000 in D2 and 200 in E2, I need 200 numbers like this:

E1000
E1001
E1002
...
E1200

I'll be attaching this code to a button.

Thanks for your help in advance.

Percy
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
For a macro, try:
Code:
Sub Combine()
Dim Ltr As String, Num As Long, lRow As Long

Ltr = Range("C2").Value
Num = Range("D2").Value
lRow = 1
For Num = Num To Range("E2").Value
    Cells(lRow, "A").Value = Ltr & Num
    lRow = lRow + 1
Next Num

End Sub
 
Upvote 0
You can also try
Code:
Dim FillRange As Range

Set FillRange = Range("G1")
Set FillRange = FillRange.Resize(Range("E2"))
FillRange.Item(1, 1).Select
FillRange.Formula = "=$C$2&($D$2+ROW()-ROW(" & _
    FillRange.Item(1, 1).Address & "))"
FillRange.Copy
FillRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False

Just change Range("G1") to the proper range to copy the data.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,496
Members
449,089
Latest member
Raviguru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top