Has Text Enough Space in a cell

M

Marcel

Hello,

I would like to test if myValue has enough space (place) to be written in a
cell.

I know the width of my cell with

Set selected_cell = Target.Cells(1, 1)
Debug.Print selected_cell .Width

What is the width of the value?

Dim myValue as string
myValue = "a value from database"

selected_cell.value = myValue

Reason: I would like that the whole value has place in the cell, otherwise I
would shorten the value.

I need A function like width(cell, myValue) this depends on the font in the
cell
Any Hints

Thanks
Marcel
 

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