Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7810885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:57:21+00:00 2026-06-02T03:57:21+00:00

In my Excel sheet, I have VBA code to detect the last non-empty cell

  • 0

enter image description here

In my Excel sheet, I have VBA code to detect the last non-empty cell in Column A and add incremental serial number value in that cell (in below example cell A6 value should be SN104).

This processing is limited only to Column A, and in this image example first non-empty last cell is at A6, sometimes it can be after 100 cells or 1000 cells.

Is there any simple way to handle this scenario?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:57:23+00:00Added an answer on June 2, 2026 at 3:57 am

    Something like

    Dim lngLastUsedRow as Integer
    lngLastUsedRow = Range("A65536").End(xlUp).Row
    
    Dim lngFirstEmptyRow as Integer
    lngFirstEmptyRow = Range("A65536").End(xlUp).Offset(1,0)
    
    // do your increment
    newValue = Cint(Mid(CurrentWorkSheet.Range("A" + lngLastUsedRow).Value,2)) + 1
    
    CurrentWorkSheet.Range("A" & lngFirstEmptyRow).Value = "SN" + newValue
    

    I don’t have excel on me, I can’t test it right now. But this should get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel sheet with two column, one is a number , and
I have one excel file (*.xlsm) with VBA code on first sheet: Private Sub
In a cell in Excel sheet I have a Date value like: 01/01/2010 14:30:00
Win-XP / Excel 2003 / VBA .... I have the following piece of code
I have something of the following : Sheet 1 (Name Range : Code) Column
Possible Duplicate: Copy column from one Excel sheet to another Excel sheet I have
We currently have an Excel spreadsheet containing a large amount of VBA code. The
I have a problem with my VBA code in an excel spreadsheet containing orders.
As I understand it when I create an Excel sheet with VBA code the
I have the following code in VBA (which resides in an Excel 2007 Workbook):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.