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 9240227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:09:11+00:00 2026-06-18T08:09:11+00:00

Need help with creating an excel macro when you click on the new button

  • 0

Need help with creating an excel macro
when you click on the new button it would look in sheet2 in column c row 2 and find the last number that was input and then add 1 and return that new number in cell D3

so in sheet2 column c row 2 would be CI300 and it would add CI301 underneath and return that number in sheet1 column d row 3

Ive been trying to find examples for the past 2 days on something similar found a few but only one was close but it had errors and was not the same

thanks

  • 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-18T08:09:12+00:00Added an answer on June 18, 2026 at 8:09 am

    This should work …

    Sub Btn_NextNum_Click()
    Dim KeyStart As Range, LastNum, NewNum
    
        Set KeyStart = Sheets("Sheet2").[C2]   ' bad bad hard coding, but you asked for it
        If KeyStart(2, 1) = "" Then
            LastNum = KeyStart
        Else
            LastNum = KeyStart(KeyStart.End(xlDown).Row - 1, 1)
        End If
    
        NewNum = "CI" & Val(Mid(LastNum, 3)) + 1
    
        If KeyStart(2, 1) = "" Then
            KeyStart(2, 1) = NewNum
        Else
            KeyStart(KeyStart.End(xlDown).Row, 1) = NewNum
        End If
    
        Sheets("Sheet1").[D3] = NewNum         ' bad bad hard coding, but you asked for it
    
    End Sub
    

    Note I hate hard coding of cell addresses … IMHO it would be better to use range names for the start of the key column and the output cell or direct the output to Selection so that the button places your NextNum whereever the cursor might be.

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

Sidebar

Related Questions

I need help creating separate text files from each row in an excel spread
I need help creating a string editing macro for excel in visual basic. I
I need help creating a regular expression for redirecting my old URL's to new
i need some help with creating file Im trying in the last hours to
I am creating a new chart for each row of data in an Excel
I'm new to C++ and I need some help creating this program: I need
I'm new in rails and need some help creating a Nested form. I have
I need help with creating a C# method that returns the index of the
I need a little help creating a catch-all error handling page in my ICEfaces
I just need help. Basically I am creating a windows appllication that sends bulk

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.