Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Append columns to existing worksheet? Chris Burnette Excel Programming 0 November 2nd 05 08:51 PM
How do I, in a marco VBA, code to take data from excel and append it to Access? Pete[_24_] Excel Programming 1 November 2nd 05 06:58 PM
How do I paste to append instead of replace existing data? Joel Thomas Excel Discussion (Misc queries) 1 October 3rd 05 01:32 PM
How to append existing series? Michael C via OfficeKB.com Charts and Charting in Excel 1 August 20th 05 03:17 PM
Help modify simple existing code?? ali Excel Programming 7 December 30th 03 11:03 PM


All times are GMT +1. The time now is 10:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"