View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default vba format question

This code seems to work for me with the sheet with A1 holding 3 in it
currently active:

Dim myText As String
myText = Format(ActiveSheet.Cells(1), "00")
MsgBox myText


"David" wrote:

cells(1).value = 3
With code I would like to convert this value into 03 for use elsewhere
ie:show single digit numbers as 2 digit in a message box
I've tried variations of the code below but no joy so far

dim txt as string
txt = format(cells(1).value, "00")
msgbox txt