Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Developers    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
VBA Sequential Numbering
Justene Justene 

4 years ago
I need to import an Excel file using VBA. I want to delete the contents of the existing Access table first then import the Excel file and number the records sequentially from 1. Autonumber obviously won't work for this. Any ideas please?
Richard Rost  @Reply  
          
4 years ago
Richard Rost  @Reply  
          
4 years ago
Kevin Robertson  @Reply  
           
4 years ago
Use a Number field instead of an AutoNumber then you can increment the numbers in your VBA.

Sequential Numbers
Justene Justene OP  @Reply  

4 years ago
Thank you. :)
Justene Justene OP  @Reply  

4 years ago
My data won't be entered via a form but will be imported from an Excel file. How can I change the code to accommodate this?
Kevin Yip  @Reply  
     
4 years ago
Put the sequential numbers on your Excel sheet first before importing it to Access.  That would be easier to do.  Just add a column on the Excel sheet and fill it with 1, 2, 3, etc.  Excel has a fast way to fill cells with a sequence of numbers too.
Justene Justene OP  @Reply  

4 years ago
Thanks Kevin. I'm trying to avoid making any changes to the Excel file before importing it into Access so it's easier for other users. I'm hoping there is a way to do this with VBA.
Kevin Yip  @Reply  
     
4 years ago
Hi Justine, you can make a copy of the Excel file and only modify that copy.  

If you want to do it in Access, you need to use VBA to run a "Recordset loop" to go through every record and add a counter to each.  It would be much easier to add counters in Excel instead.

The videos suggested to you earlier are only for setting up counters for future data entry, not for existing data which is what you have.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developers.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/12/2026 3:24:52 PM. PLT: 1s