Thanks in advance!
I am attempting to write a VBA routine that takes the Left and Right from and in between insert a value that happens to be numeric. It needs to be 3 characters long with leading 0 (zero's); one or two depending on the length of the number (001, 002, 010, 011, etc.). I had hoped to have the user insert the numeric value in a prompt and then have the job loop through the column and complete the insert. The issue I am having is that no matter what I have done to try to convert the variable to string, the leading 0's are dropped. I have tried
Dim LineNum as string
LineNum = Str$(Right("00000" & CStr(LineNum), 3)) (type mismatch
LineNum = Str$(Right(00000 & CStr(LineNum), 3)) outputs the interger value with no leading 0's.
I have tried inputting 001 in the like so
LineNum = Str$(InputBox("Enter line number"))
then looping with
Range("H" & rowHdr).Formula = "=Left(B" & rowHdr & ",13)& " & CStr(LineNum) & "& Right(B" & rowHdr & ",4)"
Is there a way to get the leading 0's in the formula?
Thanks,
Lee