ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem changing numbers in a string (https://www.excelbanter.com/excel-programming/431316-problem-changing-numbers-string.html)

HarryGuy

Problem changing numbers in a string
 
I have a string that contains something like the following.
a=10%b=1%c=19%d=06%e=18%f=20%
I need to change the numbers to new numbers contained on a Master sheet.

For example: if the new number in Master(3, 1) = "1" and the new number in
Master(3, 2) = "15". I want the string to now read a=1%b=15%, etc.

This new string then will be changed again with yet new numbers over and
over again as neded by the program

I hope I have made it clear. Can someone please help me with this



joel

Problem changing numbers in a string
 
You need to remove the old data from the sring. You didn't provide enough
info to be able to remove the old string. Here is how to build the new string

a = 1
b = 2
c = 3
d = 4
e = 5

MyStr = "a=" & a & "%b=" & b & "%c=" & c & "%d=" & d & "%e=" e & "%"


"HarryGuy" wrote:

I have a string that contains something like the following.
a=10%b=1%c=19%d=06%e=18%f=20%
I need to change the numbers to new numbers contained on a Master sheet.

For example: if the new number in Master(3, 1) = "1" and the new number in
Master(3, 2) = "15". I want the string to now read a=1%b=15%, etc.

This new string then will be changed again with yet new numbers over and
over again as neded by the program

I hope I have made it clear. Can someone please help me with this




Don Guillett

Problem changing numbers in a string
 
You didn't give much detail but you should be able to use this idea.

Sub changenumbers()
Application.ScreenUpdating = False
For Each c In Selection
v1 = "a=" & [h1] & "%"
v2 = "b=" & [h2] & "%"
v3 = "c=" & [h3] & "%"
v4 = "d=" & [h4] & "%"
v5 = "e=" & [h5] & "%"
For i = 1 To 5
c.Value = v1 & v2 & v3 & v4 & v5
Next i
Next c
Application.ScreenUpdating = True
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"HarryGuy" wrote in message
...
I have a string that contains something like the following.
a=10%b=1%c=19%d=06%e=18%f=20%
I need to change the numbers to new numbers contained on a Master sheet.

For example: if the new number in Master(3, 1) = "1" and the new number in
Master(3, 2) = "15". I want the string to now read a=1%b=15%, etc.

This new string then will be changed again with yet new numbers over and
over again as neded by the program

I hope I have made it clear. Can someone please help me with this




Don Guillett

Problem changing numbers in a string
 
Oops. Left something in

Sub changenumbers()
Application.ScreenUpdating = False
For Each c In Selection
v1 = "a=" & [h1] & "%"
v2 = "b=" & [h2] & "%"
v3 = "c=" & [h3] & "%"
v4 = "d=" & [h4] & "%"
v5 = "e=" & [h5] & "%"
c.Value = v1 & v2 & v3 & v4 & v5
Next c
Application.ScreenUpdating = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
You didn't give much detail but you should be able to use this idea.

Sub changenumbers()
Application.ScreenUpdating = False
For Each c In Selection
v1 = "a=" & [h1] & "%"
v2 = "b=" & [h2] & "%"
v3 = "c=" & [h3] & "%"
v4 = "d=" & [h4] & "%"
v5 = "e=" & [h5] & "%"
For i = 1 To 5
c.Value = v1 & v2 & v3 & v4 & v5
Next i
Next c
Application.ScreenUpdating = True
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"HarryGuy" wrote in message
...
I have a string that contains something like the following.
a=10%b=1%c=19%d=06%e=18%f=20%
I need to change the numbers to new numbers contained on a Master sheet.

For example: if the new number in Master(3, 1) = "1" and the new number
in Master(3, 2) = "15". I want the string to now read a=1%b=15%, etc.

This new string then will be changed again with yet new numbers over and
over again as neded by the program

I hope I have made it clear. Can someone please help me with this





Rick Rothstein

Problem changing numbers in a string
 
For what you have shown us, this will create the string you want to a
variable named OutString which you can then use in any way you need to...

For X = 1 To UBound(Master, 2)
OutString = OutString & Chr(96 + X) & "=" & Master(3, X) & "%"
Next

--
Rick (MVP - Excel)


"HarryGuy" wrote in message
...
I have a string that contains something like the following.
a=10%b=1%c=19%d=06%e=18%f=20%
I need to change the numbers to new numbers contained on a Master sheet.

For example: if the new number in Master(3, 1) = "1" and the new number in
Master(3, 2) = "15". I want the string to now read a=1%b=15%, etc.

This new string then will be changed again with yet new numbers over and
over again as neded by the program

I hope I have made it clear. Can someone please help me with this




HarryGuy

Problem changing numbers in a string
 
Thanks very much to all who answered my call. I now have it working so on to
the next problem. Thanks again.


"HarryGuy" wrote in message
...
I have a string that contains something like the following.
a=10%b=1%c=19%d=06%e=18%f=20%
I need to change the numbers to new numbers contained on a Master sheet.

For example: if the new number in Master(3, 1) = "1" and the new number in
Master(3, 2) = "15". I want the string to now read a=1%b=15%, etc.

This new string then will be changed again with yet new numbers over and
over again as neded by the program

I hope I have made it clear. Can someone please help me with this






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com