Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Prefix macro

I deal with the same problem all the time. I would like to create
macro for a colum of data that would allow me to insert a custom
character text prefix to the data.
For example in Col A the cells are populated with a Part Number i
cell A1= 100-600125, cell A2 = 500-235487, cell A3 = 547-255684, etc.

I would like to add a prefix to all of the cells in the colum ie "PRE-
so that the results would be each cell has the prefix added to it, i
cell A1 = PRE-100-600125, cell A2 = PRE-500-235487, etc.

I hope this is clear. Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Prefix macro

I figured it out. Thank

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Prefix macro

Sub insertprefix()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Dim cell As Range
Dim myPrefix As String
myPrefix = "'"
myPrefix = InputBox("Supply prefix character(s)", "Supply prefix"
myPrefix)
For Each cell In Intersect(Selection, ActiveSheet.UsedRange)
If Len(Trim(cell)) 0 Then _
cell.Formula = myPrefix & cell.Text
Next cell
Application.Calculation = xlAutomatic 'xlCalculationAutomatic
Application.ScreenUpdating = False
End Su

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Prefix macro

Ted

Here's a generic macro that allows you to choose to add inputted text left or
right of existing data.

Sub Add_Text()
Dim cell As Range
Dim moretext As String
Dim thisrng As Range
On Error GoTo endit
whichside = InputBox("Left = 1 or Right =2")
Set thisrng = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
moretext = InputBox("Enter your Text")
If whichside = 1 Then
For Each cell In thisrng
cell.Value = moretext & cell.Value
Next
Else
For Each cell In thisrng
cell.Value = cell.Value & moretext
Next
End If
Exit Sub
endit:
MsgBox "only formulas in range"
End Sub

Gord Dibben Excel MVP

On Tue, 6 Jul 2004 09:57:36 -0500, TedL
wrote:

I deal with the same problem all the time. I would like to create a
macro for a colum of data that would allow me to insert a custom 4
character text prefix to the data.
For example in Col A the cells are populated with a Part Number ie
cell A1= 100-600125, cell A2 = 500-235487, cell A3 = 547-255684, etc.

I would like to add a prefix to all of the cells in the colum ie "PRE-"
so that the results would be each cell has the prefix added to it, ie
cell A1 = PRE-100-600125, cell A2 = PRE-500-235487, etc.

I hope this is clear. Thanks.


---
Message posted from http://www.ExcelForum.com/


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
Prefix dleo Excel Discussion (Misc queries) 0 July 1st 09 05:18 PM
omit the ns1: prefix Gerald Piotrowski Excel Discussion (Misc queries) 0 March 5th 08 07:22 PM
SUM without prefix Boris Excel Discussion (Misc queries) 3 January 2nd 08 11:40 AM
cell prefix Johno313 Excel Discussion (Misc queries) 4 June 20th 06 10:35 AM
Prefix Big Boss Excel Worksheet Functions 4 August 11th 05 03:05 AM


All times are GMT +1. The time now is 03:24 PM.

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

About Us

"It's about Microsoft Excel"