Problem changing numbers in a string

H

HarryGuy

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
 
J

Joel

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 & "%"
 
D

Don Guillett

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
 
D

Don Guillett

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
(e-mail address removed)
Don Guillett said:
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
(e-mail address removed)
HarryGuy said:
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
 
R

Rick Rothstein

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
 
H

HarryGuy

Thanks very much to all who answered my call. I now have it working so on to
the next problem. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top