multiply text and number

L

Lucy

Hi there, I'm writing a UDF and trying to multiply text and number. (Answer
will show in text)

Function Pallet(MyNum)
Dim i As Integer
i = MyNum Mod 20
Dim j As Integer
j = Fix(MyNum / 20)

if i >= 9 and i <= 12 then "L" should appear (j-1) times
Let's say MyNum = 72
So, i = MyNum Mod 20 = 12
And j = Fix(MyNum / 20) = 3

I want the answer shows letter "L" appear (j-1) times, which is 2 times
like this : LL [in text format]

Is it possible?

Since outside this UDF, I count the total occurences of letter "L" in a
range. Therefore, i prefer answer in here shows "LL" instead of "2 L"

Thank you.
 
J

Joel

Function Pallet(MyNum) As String
Pallet = String(Int(MyNum / 20) - 1, "L")
End Function
 
L

Lucy

Thanks Joel, it works perfect!

Joel said:
Function Pallet(MyNum) As String
Pallet = String(Int(MyNum / 20) - 1, "L")
End Function

Lucy said:
Hi there, I'm writing a UDF and trying to multiply text and number. (Answer
will show in text)

Function Pallet(MyNum)
Dim i As Integer
i = MyNum Mod 20
Dim j As Integer
j = Fix(MyNum / 20)

if i >= 9 and i <= 12 then "L" should appear (j-1) times
Let's say MyNum = 72
So, i = MyNum Mod 20 = 12
And j = Fix(MyNum / 20) = 3

I want the answer shows letter "L" appear (j-1) times, which is 2 times
like this : LL [in text format]

Is it possible?

Since outside this UDF, I count the total occurences of letter "L" in a
range. Therefore, i prefer answer in here shows "LL" instead of "2 L"

Thank you.
 

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