Data Fill: easier way than this VBA?

sjk

New Member
Joined
Apr 8, 2002
Messages
14
I am constantly adding rows to an Excel database, and I want to automatically number the records from 1 to x, x being last row. The code that follows works - but seems awkward because, since my data starts at row 6, I have to subtract 5 from the Row (function?). I thought that I could use .Count, but it didn't work. What is the command/function to count the total rows (not the row number) and then use it as a variable to auto fill to?

Sub colfill()
'
' colfill Macro
' Macro recorded 4/16/2002 by Preferred Customer
'
Range("a6") = 1
RowCount = Range("b6").End(xlDown).Row - 5
'
Application.Goto Reference:="R6C1"
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Stop:=RowCount, Trend:=False
End Sub

Thanks, SJK
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi sjk. Pls try this.

Sub colfill()
Range("A6").Value = 1
Range("A6", Range("B65536").End(xlUp).Offset(, -1)).DataSeries 2, Step:=1
End Sub

Regards,
Colo
 
Upvote 0
Hi Colo: Yes, your program worked perfectly. I am trying to learn VBA and I am somewhat overwhelmed. Can I ask: did you know the solution just from experience, or did you look it up? I know that some basic ones can be built by using the Macro recorder. Thanks, SJK.
 
Upvote 0
Hi sjk.
I began to use "excel" since two years ago.Those days, I could only use the Macro recorder.
There was no person using Excel around me.
So, how to solve my problem was read the help and watched some web site.
The persons who have own problem gather on bbs site.
On the site, I could find the topic which could solve my problem.

Regards,
Colo
 
Upvote 0
Hi Colo: Thanks for the advice. I am gradually learning. I agree: this site is very helpful. I have also found it helpful to take some programming language and go through it line by line, and even to re-enter the code. Sructures become familiar.. SJK
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

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