Convert MM to inch and add to comment

  • Thread starter Thread starter rpick60
  • Start date Start date
R

rpick60

How would I convert a number from MM to Inch and add the results to
the comment?
here is what is the cell
800X400X300
the results can be entered in to a comment
31.496X15.748X11.811
or
31.496
15.748
11.811

the formula is 800/25.4= 31.496

Thanks in advanced
 
This sub does the job with activecell, adjust ranges as required!
Change "X" to Chr(10) for second format!

Sub mmtoinch()
dimarray = Split(ActiveCell, "X")
ActiveCell.ClearComments
ActiveCell.AddComment (Format(dimarray(0) / 25.4, "###.000") & "X" & _
Format(dimarray(1) / 25.4, "###.000") & "X" & _
Format(dimarray(2) / 25.4, "###.000"))
End Sub

Regards,
Stefi

„rpick60†ezt írta:
 
This sub does the job with activecell, adjust ranges as required!
Change "X" to Chr(10) for second format!

Sub mmtoinch()
dimarray = Split(ActiveCell, "X")
ActiveCell.ClearComments
ActiveCell.AddComment (Format(dimarray(0) / 25.4, "###.000") & "X" & _
Format(dimarray(1) / 25.4, "###.000") & "X" & _
Format(dimarray(2) / 25.4, "###.000"))
End Sub

Regards,
Stefi

„rpick60" ezt írta:






- Show quoted text -

Thanks it work great
 
the results can be entered into a comment
31.496X15.748X11.811

Just a technique for display might be to use the Multiplication symbol
instead of the letter X.

Sub Demo()
Dim j As Long
Dim v As Variant

With ActiveCell
'// Remove...
.Value = "800X400X300"

v = Split(Trim(.Value), "X")

For j = LBound(v) To UBound(v)
v(j) = Format(v(j) / 25.4, "#.000")
Next j

.ClearComments
.AddComment Join(v, Space(1) & Chr(215) & Space(1))
.Comment.Shape.TextFrame.AutoSize = True
End With
End Sub
 

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

Back
Top