![]() |
Simple code to append numbers to the existing data in the cells
Hello
I have many colums of data (characters) What I want to do is, highlight the required cells in the column and then either press a button or whatever to trigger the code to run. The code should append numbers to the existing data. for e.g: Column: AA BB TH XH HB SO I want the code to do this: 30AA 31BB 32TH 33XH 34HB 35SO Can the code ask me what is the starting number I want to append? Can somebody show me a sample how to do this? Thank you very much. |
Simple code to append numbers to the existing data in the cells
Hello Hemang Shah, This macro will prompt you for a starting number and then appen it t the data in the cells you have selected. The cells need not b contiguous. Add a VBA module to your project and paste this macro into. You ca then assign the macro to an object or run it using the Macro Dialo (press ALT+F8 while in Excel). Code ------------------- Sub AppendNumber() Dim Answer Dim ChoosenCells As Range Dim I As Long Answer = InputBox("Enter your starting sequence number.") If Answer = "" Then Exit Sub I = Answer For Each ChoosenCell In Selection With ChoosenCell .Value = I & .Text End With I = I + 1 Next ChoosenCell End Sub ------------------- Sincerely, Leith Ros -- Leith Ros ----------------------------------------------------------------------- Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846 View this thread: http://www.excelforum.com/showthread.php?threadid=55481 |
All times are GMT +1. The time now is 03:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com