Next number from a reference list

kbar

New Member
Joined
Jul 23, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Okay I am new to macros and this feels like it should be very simple but I need some help. I have a template for creating quotes and a macro that records information from the quote to another sheet including the quote number. I have another macro that then clears certain cells on the quote to prepare for the next one. With this I also want the quote number to update to the next available by referencing the list of already recorded quote numbers from column A on Sheet 3. I can't figure out how to get the code to reference all of column A and return the next number in sequence. Below is the code I am working with but the Range("A:A") part does not work. When I made it a specific cell like A2 then it has no problem returning the next number after what's in A2 but I need it to look through all of column A. Noting that the quote quote number structure is "CH-00001".


Sheet1.Range("I6:M6,A10:D10,B18:H28,K18:K28,F10:M14").ClearContents
Sheet1.Range("I5").Value = Left(Sheet3.Range("A:A").Value, 3) & Mid(Sheet3.Range("A:A").Value, 4, 5) + 1
MsgBox "Your next Change Order number is " & Sheet1.Range("I5")
 

Attachments

  • 1721770137928.png
    1721770137928.png
    44.9 KB · Views: 5

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
A simple solution would be to just record the unformatted numeric value in sheet3 column A e.g. instead of recording CH-00001 just record a 1.

Then in sheet1 I5, have the Cell's custom number formatting as "CH-"00000 and the formula =MAX(Sheet3!A:A)+1

You could also format Sheet3 column A with the same custom number format. The actual numeric value in the cell doesn't change with the custom number format. Only how the numeric value is displayed changes.
 
Upvote 0

Forum statistics

Threads
1,223,867
Messages
6,175,074
Members
452,611
Latest member
bls2024

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