PDA

View Full Version : How to move data from one variable to another



metz
04-04-2021, 11:43 PM
Hi
I am a beginner in VBA.
Could anyone help me with this simple question.

I want to move a string from one variable to a specific position of another variable.
For example;
A = "abcedfgh"
B = "xyz"

I want to move B to the third byte of A, so the result value of A will become "abxyzfgh".
How can I do it in VBA?

Thanks in advance.

metz

Paul_Hossler
04-05-2021, 06:29 AM
A = Left(A,2) & B & Right(A, Len(A)-2)

p45cal
04-05-2021, 07:08 AM
A = Replace(A, Mid(A, 3, Len(B)), B,,1)

metz
04-05-2021, 01:19 PM
A = Left(A,2) & B & Right(A, Len(A)-2)



Thanks Paul :yay

metz
04-05-2021, 01:20 PM
Thanks guys :bow:

snb
04-06-2021, 08:11 AM
Sub M_snb()
a = "abcedfgh"
b = "xyz"

sn = Split(StrConv(a, 64), Chr(0))
sn(2) = b & sn(2)
a = Join(sn, "")

MsgBox a
End Sub