Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Replace text with numbers.

I'm working with importing text files into Excel that have account
names listed in one column and I'd like to repalce the account name
with an account number. For Example, I would like to replace the name
ADVERTISING with the number 63100 and I would like to replace the name
PURCHASES with the number 51000. I would like to know if someone
would be able to get me started with an Excel macro that I would just
be able to continue the same formatting, adding records to achieve the
same results but within a shorter period of time. Does anybody have
an idea of how to help me get this one started?

Thanks for helping,

Josh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Replace text with numbers.

Columns("A:A").Select
Selection.Replace What:="advertising", Replacement:="61300",
LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Purchases", Replacement:="51000",
LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False


or
Sub MakeReplacements()
dim varr as variant, varr1 as variant, i as long
varr = Array("advertising", "purchases")
varr1 = Array(63100, 51000)
for i = lbound(varr) to ubound(varr)
Columns(A:A).Replace What:=varr(i), Replacement:=varr1(i), _
LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False
Next i
End Sub


--
Regards,
Tom Ogilvy


"Josh" wrote in message
om...
I'm working with importing text files into Excel that have account
names listed in one column and I'd like to repalce the account name
with an account number. For Example, I would like to replace the name
ADVERTISING with the number 63100 and I would like to replace the name
PURCHASES with the number 51000. I would like to know if someone
would be able to get me started with an Excel macro that I would just
be able to continue the same formatting, adding records to achieve the
same results but within a shorter period of time. Does anybody have
an idea of how to help me get this one started?

Thanks for helping,

Josh



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Replace text with numbers.

Take a look at the standard Excel vlookup function, in any event you'll need
a look up table to convert from the text data to a numerical value, perhaps
on another sheet. Unless you wish to hard code these into a program (not
usually recommended for dynamic data). How do you intend to establish the
translation and maintain it?

Cheers
Nigel

"Josh" wrote in message
om...
I'm working with importing text files into Excel that have account
names listed in one column and I'd like to repalce the account name
with an account number. For Example, I would like to replace the name
ADVERTISING with the number 63100 and I would like to replace the name
PURCHASES with the number 51000. I would like to know if someone
would be able to get me started with an Excel macro that I would just
be able to continue the same formatting, adding records to achieve the
same results but within a shorter period of time. Does anybody have
an idea of how to help me get this one started?

Thanks for helping,

Josh



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Replace text with numbers.

There appears to be syntax errors in the following assertions:

Columns(A:A).Replace What:=varr(i), Replacement:=varr1(i), _
LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False

and

Selection.Replace What:="advertising", Replacement:="61300",
LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Purchases", Replacement:="51000",
LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False

They all appear in red when I copy/paste it into VB editor. I have
Excel 2000.






*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Replace text with numbers.

You can ignore these since you have posted again with different
requirements.

--
Regards,
Tom Ogilvy

"Josh Webskowski" wrote in message
...
There appears to be syntax errors in the following assertions:

Columns(A:A).Replace What:=varr(i), Replacement:=varr1(i), _
LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False

and

Selection.Replace What:="advertising", Replacement:="61300",
LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False
Selection.Replace What:="Purchases", Replacement:="51000",
LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False

They all appear in red when I copy/paste it into VB editor. I have
Excel 2000.






*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Find/Replace Numbers stored as Text drops zeros mduncan1153 Excel Discussion (Misc queries) 1 April 21st 10 07:19 PM
Pivot Table - replace numbers with a text vinstream Excel Discussion (Misc queries) 1 April 6th 10 10:48 AM
Can I replace a ' at the beginning of a text cell using Replace Hilde Excel Discussion (Misc queries) 4 September 10th 07 06:22 PM
Replace numbers on x-axis of scatter chart with text eg 1 - one sfran19 Charts and Charting in Excel 3 November 20th 06 05:42 PM
How to Replace numbers and text with numbers only? Robert Judge Excel Worksheet Functions 3 November 5th 04 04:36 PM


All times are GMT +1. The time now is 02:04 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"